From b3b3578f0888c1f224708dc23f2d8dc7878ef807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 14 Jul 2013 22:50:38 +0200 Subject: [PATCH 01/63] Nominal support for target Ohio Scientific Challenger 1P --- cfg/c1p.cfg | 30 +++++++++++++++++++++++++ libsrc/Makefile | 1 + libsrc/c1p/crt0.s | 54 +++++++++++++++++++++++++++++++++++++++++++++ src/ca65/main.c | 4 ++++ src/cc65/main.c | 4 ++++ src/common/target.c | 4 +++- src/common/target.h | 1 + 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 cfg/c1p.cfg create mode 100644 libsrc/c1p/crt0.s diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg new file mode 100644 index 000000000..752e81533 --- /dev/null +++ b/cfg/c1p.cfg @@ -0,0 +1,30 @@ +SYMBOLS { + __STACKSIZE__: type = weak, value = $0400; # 1k stack +} +MEMORY { + ZP: file = "", define = yes, start = $0002, size = $001A; + LOADADDR: file = %O, start = $0FFF, size = $0002; + HEADER: file = %O, start = $1001, size = $000C; + RAM: file = %O, define = yes, start = $100D, size = $0DF3 - __STACKSIZE__; +} +SEGMENTS { + STARTUP: load = RAM, type = ro; + LOWCODE: load = RAM, type = ro, optional = yes; + INIT: load = RAM, type = ro, define = yes, optional = yes; + CODE: load = RAM, type = ro; + RODATA: load = RAM, type = ro; + DATA: load = RAM, type = rw; + ZPSAVE: load = RAM, type = bss; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; +} diff --git a/libsrc/Makefile b/libsrc/Makefile index d855d1580..9955d6d77 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -15,6 +15,7 @@ TARGETS = apple2 \ atari \ atarixl \ atmos \ + c1p \ $(CBMS) \ $(GEOS) \ lynx \ diff --git a/libsrc/c1p/crt0.s b/libsrc/c1p/crt0.s new file mode 100644 index 000000000..f8005b6dd --- /dev/null +++ b/libsrc/c1p/crt0.s @@ -0,0 +1,54 @@ +; --------------------------------------------------------------------------- +; crt0.s +; --------------------------------------------------------------------------- +; +; Startup code for Ohio Scientific Challenger 1P + +.export _init, _exit +.import _main + +.export __STARTUP__ : absolute = 1 ; Mark as startup +.import __RAM_START__, __RAM_SIZE__ ; Linker generated + +.import copydata, zerobss, initlib, donelib + +.include "zeropage.inc" + +; --------------------------------------------------------------------------- +; Place the startup code in a special segment + +.segment "STARTUP" + +; --------------------------------------------------------------------------- +; A little light 6502 housekeeping + +_init: LDX #$FF ; Initialize stack pointer to $01FF + TXS + CLD ; Clear decimal mode + +; --------------------------------------------------------------------------- +; Set cc65 argument stack pointer + + LDA #<(__RAM_START__ + __RAM_SIZE__) + STA sp + LDA #>(__RAM_START__ + __RAM_SIZE__) + STA sp+1 + +; --------------------------------------------------------------------------- +; Initialize memory storage + + ; JSR zerobss ; Clear BSS segment + ; JSR copydata ; Initialize DATA segment + ; JSR initlib ; Run constructors + +; --------------------------------------------------------------------------- +; Call main() + + JSR _main + +; --------------------------------------------------------------------------- +; Back from main (this is also the _exit entry): force a software break + +_exit: JSR donelib ; Run destructors + BRK + diff --git a/src/ca65/main.c b/src/ca65/main.c index 4b2f9d178..5a9bf7083 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -298,6 +298,10 @@ static void SetSys (const char* Sys) NewSymbol ("__SIM65C02__", 1); break; + case TGT_C1P: + NewSymbol ("__OSIC1P__", 1); + break; + default: AbEnd ("Invalid target name: `%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index a27822ed8..6882d56a3 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -254,6 +254,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__SIM65C02__", 1); break; + case TGT_C1P: + DefineNumericMacro ("__OSIC1P__", 1); + break; + default: AbEnd ("Unknown target system type %d", Target); } diff --git a/src/common/target.c b/src/common/target.c index a4287ee56..d8d3f9c54 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -119,7 +119,7 @@ struct TargetEntry { }; /* Table that maps target names to ids. Sorted alphabetically for bsearch. - * Allows mupltiple entries for one target id (target name aliases). + * Allows multiple entries for one target id (target name aliases). */ static const TargetEntry TargetMap[] = { { "apple2", TGT_APPLE2 }, @@ -130,6 +130,7 @@ static const TargetEntry TargetMap[] = { { "bbc", TGT_BBC }, { "c128", TGT_C128 }, { "c16", TGT_C16 }, + { "c1p", TGT_C1P }, { "c64", TGT_C64 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, @@ -160,6 +161,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "atarixl", CPU_6502, BINFMT_BINARY, CTAtari }, { "vic20", CPU_6502, BINFMT_BINARY, CTPET }, { "c16", CPU_6502, BINFMT_BINARY, CTPET }, + { "c1p", CPU_6502, BINFMT_BINARY, CTNone }, { "c64", CPU_6502, BINFMT_BINARY, CTPET }, { "c128", CPU_6502, BINFMT_BINARY, CTPET }, { "plus4", CPU_6502, BINFMT_BINARY, CTPET }, diff --git a/src/common/target.h b/src/common/target.h index e1675ad65..47946a309 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -58,6 +58,7 @@ typedef enum { TGT_ATARIXL, TGT_VIC20, TGT_C16, + TGT_C1P, TGT_C64, TGT_C128, TGT_PLUS4, From 0303b0cc6c29115cb4fbc819f574c9073dc6c643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Mon, 15 Jul 2013 22:24:10 +0200 Subject: [PATCH 02/63] Adapt to memory size of C1P. --- cfg/c1p.cfg | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index 752e81533..f1d739215 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -3,20 +3,17 @@ SYMBOLS { } MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; - LOADADDR: file = %O, start = $0FFF, size = $0002; - HEADER: file = %O, start = $1001, size = $000C; - RAM: file = %O, define = yes, start = $100D, size = $0DF3 - __STACKSIZE__; + RAM: file = %O, define = yes, start = $0400, size = $2000 - __STACKSIZE__; } SEGMENTS { - STARTUP: load = RAM, type = ro; - LOWCODE: load = RAM, type = ro, optional = yes; - INIT: load = RAM, type = ro, define = yes, optional = yes; - CODE: load = RAM, type = ro; - RODATA: load = RAM, type = ro; - DATA: load = RAM, type = rw; - ZPSAVE: load = RAM, type = bss; - BSS: load = RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp; + STARTUP: load = RAM, type = ro; + LOWCODE: load = RAM, type = ro, optional = yes; + INIT: load = RAM, type = ro, define = yes, optional = yes; + CODE: load = RAM, type = rw; + RODATA: load = RAM, type = rw; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; } FEATURES { CONDES: type = constructor, From 608e9875fb37c094f312ca2ac05e3abe10ab034f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Mon, 15 Jul 2013 22:45:09 +0200 Subject: [PATCH 03/63] Suppress call to copydata routine, which seems to be necessary only in very special cases that are unclear at the moment. --- libsrc/c1p/crt0.s | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libsrc/c1p/crt0.s b/libsrc/c1p/crt0.s index f8005b6dd..fcbb82e64 100644 --- a/libsrc/c1p/crt0.s +++ b/libsrc/c1p/crt0.s @@ -36,10 +36,11 @@ _init: LDX #$FF ; Initialize stack pointer to $01FF ; --------------------------------------------------------------------------- ; Initialize memory storage +; copydata seems to be only necessary for special systems - ; JSR zerobss ; Clear BSS segment - ; JSR copydata ; Initialize DATA segment - ; JSR initlib ; Run constructors + JSR zerobss ; Clear BSS segment + ; JSR copydata ; Initialize DATA segment + JSR initlib ; Run constructors ; --------------------------------------------------------------------------- ; Call main() From 9b505d7b6513e0082df17661674862f72393aee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 16 Jul 2013 22:29:14 +0200 Subject: [PATCH 04/63] Created C1P object file generator. --- src/Makefile | 1 + src/c1p65.vcxproj | 94 ++++++++++++++++++++ src/c1p65/main.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 src/c1p65.vcxproj create mode 100644 src/c1p65/main.c diff --git a/src/Makefile b/src/Makefile index 3d0463147..4a80a78fb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,7 @@ ifeq ($(shell echo),) PROGS = ar65 \ + c1p65 \ ca65 \ cc65 \ cl65 \ diff --git a/src/c1p65.vcxproj b/src/c1p65.vcxproj new file mode 100644 index 000000000..2f4ff02fb --- /dev/null +++ b/src/c1p65.vcxproj @@ -0,0 +1,94 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + {4E031DE0-82B4-4204-8529-536626F7E0DF} + Win32Proj + c1p65 + + + + Application + true + v110 + + + + + Application + false + v110 + true + + + + + + + + + + + + + + + true + $(SolutionDir)..\bin\ + $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\bin\ + $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + common + + + Console + true + $(IntDir)..\..\common\$(Configuration)\common.lib + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + common + + + Console + true + true + true + $(IntDir)..\..\common\$(Configuration)\common.lib + + + + + + \ No newline at end of file diff --git a/src/c1p65/main.c b/src/c1p65/main.c new file mode 100644 index 000000000..c15c77a88 --- /dev/null +++ b/src/c1p65/main.c @@ -0,0 +1,219 @@ +/* Object file conversion utility for Challenger 1P + + by Stephan Muehlstrasser +*/ + + +#include +#include +#include +#include +#include +#include + +/* common stuff */ +#include "abend.h" +#include "cmdline.h" +#include "fname.h" +#include "chartype.h" +#include "target.h" +#include "version.h" +#include "xmalloc.h" + +static void Usage (void) +{ + printf ( + "Usage: %s [options] file\n" + "Short options:\n" + " -V\t\t\tPrint the version number\n" + " -h\t\t\tHelp (this text)\n" + " -o name\t\tName the C1P output file (default: )\n" + " -S addr\t\tLoad address (default 0x400)\n" + "\n" + "Long options:\n" + " --help\t\tHelp (this text)\n" + " --version\t\tPrint the version number\n", + ProgName); +} + +static void OptHelp (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Print usage information and exit */ +{ + Usage (); + exit (EXIT_SUCCESS); +} + + +static void OptVersion (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Print the program version */ +{ + fprintf (stderr, "grc65 V%s\n", GetVersionAsString ()); +} + + +static unsigned long CvtNumber (const char* Arg, const char* Number) +/* Convert a number from a string. Allow '$' and '0x' prefixes for hex + * numbers. Duplicated from ld65's main.c. + */ +{ + unsigned long Val; + int Converted; + + /* Convert */ + if (*Number == '$') { + ++Number; + Converted = sscanf (Number, "%lx", &Val); + } else { + Converted = sscanf (Number, "%li", (long*)&Val); + } + + /* Check if we do really have a number */ + if (Converted != 1) { + AbEnd ("Invalid number given in argument: %s\n", Arg); + } + + /* Return the result */ + return Val; +} + +/* Commands of C1P PROM monitor */ +#define ADDRESS_MODE_CMD '.' +#define DATA_MODE_CMD '/' +#define EXECUTE_CMD 'G' + +/* Transform the cc65 executable binary into a series of + commands that make the C1P PROM monitor load the bytes + into memory. +*/ +static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) +{ + int c; + unsigned long CurrentAddress; + + /* Loop over all input bytes, position to current address, + switch to data mod, output input byte + */ + for (CurrentAddress = StartAddress, c = getc(In); + c != EOF; + c = getc(In), CurrentAddress += 1) { + fprintf (Out, "%c%04.4X%c%02.2X", + ADDRESS_MODE_CMD, (unsigned int) CurrentAddress & 0xFFFF, + DATA_MODE_CMD, (unsigned int) c & 0xFF); + } + + /* And execute + fprintf (Out, "%c%04.4x%c", + ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, + EXECUTE_CMD); + */ +} + +/* Default suffix for C1P object file */ +#define C1P_SUFFIX ".c1p" + +int main (int argc, char *argv[]) +{ + /* Program long options */ + static const LongOpt OptTab[] = { + { "--help", 0, OptHelp}, + { "--version", 0, OptVersion}, + }; + + /* Initialize input and output file name */ + const char* InputFile = 0; + const char* OutputFile = 0; + char *GeneratedOutputFile = 0; + + /* Initialize file pointers */ + FILE *InputFileFp = 0; + FILE *OutputFileFp = 0; + + /* Initialize with default start address defined in c1p.cfg */ + unsigned long StartAddr = 0x400; + + unsigned int I; + + /* Initialize the cmdline module */ + InitCmdLine (&argc, &argv, "c1p65"); + + /* Check the parameters */ + I = 1; + while (I < ArgCount) { + + /* Get the argument */ + const char* Arg = ArgVec [I]; + + /* Check for an option */ + if (Arg[0] == '-') { + switch (Arg[1]) { + + case '-': + LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); + break; + + case 'o': + OutputFile = GetArg (&I, 2); + break; + + case 'S': + StartAddr = CvtNumber (Arg, GetArg (&I, 2)); + break; + + case 'h': + case '?': + OptHelp (Arg, 0); + break; + + case 'V': + OptVersion (Arg, 0); + break; + + default: + UnknownOption (Arg); + } + + } else { + if (InputFile) { + fprintf (stderr, "additional file specs ignored\n"); + } else { + InputFile = Arg; + } + } + + /* Next argument */ + ++I; + } + + if (!InputFile) AbEnd ("No input file"); + + if (!OutputFile) { + const size_t len = strlen(InputFile) + sizeof(C1P_SUFFIX); + + GeneratedOutputFile = (char *) xmalloc(len); + sprintf(GeneratedOutputFile, "%s%s", InputFile, C1P_SUFFIX); + OutputFile = GeneratedOutputFile; + } + + /* Open input and output files */ + InputFileFp = fopen(InputFile, "rb"); + if (!InputFileFp) AbEnd ("Unable to open input file"); + + OutputFileFp = fopen(OutputFile, "wb"); + if (!OutputFileFp) AbEnd ("Unable to open output file"); + + /* Generate object file */ + Transform (StartAddr, InputFileFp, OutputFileFp); + + /* Cleanup */ + if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file"); + + if (fclose(OutputFileFp) == EOF) AbEnd ("Error closing output file"); + + if (GeneratedOutputFile) { + xfree(GeneratedOutputFile); + } + + return EXIT_SUCCESS; +} From 0b8c742bfcc5c03cba5b0c9d55d3897d66cf1f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Wed, 24 Jul 2013 22:35:58 +0200 Subject: [PATCH 05/63] Remove unneeded import --- libsrc/c1p/crt0.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/c1p/crt0.s b/libsrc/c1p/crt0.s index fcbb82e64..97d572608 100644 --- a/libsrc/c1p/crt0.s +++ b/libsrc/c1p/crt0.s @@ -10,7 +10,7 @@ .export __STARTUP__ : absolute = 1 ; Mark as startup .import __RAM_START__, __RAM_SIZE__ ; Linker generated -.import copydata, zerobss, initlib, donelib +.import zerobss, initlib, donelib .include "zeropage.inc" From 57a422d064251c6f27fe1306db0e8077492adada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 2 Nov 2014 19:39:39 +0100 Subject: [PATCH 06/63] Adapt c1p65 project to Visual Studio 2013 --- src/c1p65.vcxproj | 186 +++++++++++++++++++++++----------------------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/src/c1p65.vcxproj b/src/c1p65.vcxproj index 2f4ff02fb..dcc8f9926 100644 --- a/src/c1p65.vcxproj +++ b/src/c1p65.vcxproj @@ -1,94 +1,94 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - {4E031DE0-82B4-4204-8529-536626F7E0DF} - Win32Proj - c1p65 - - - - Application - true - v110 - - - - - Application - false - v110 - true - - - - - - - - - - - - - - - true - $(SolutionDir)..\bin\ - $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ - - - false - $(SolutionDir)..\bin\ - $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ - - - - - - Level3 - Disabled - _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - common - - - Console - true - $(IntDir)..\..\common\$(Configuration)\common.lib - - - - - Level3 - - - MaxSpeed - true - true - _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - common - - - Console - true - true - true - $(IntDir)..\..\common\$(Configuration)\common.lib - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + {4E031DE0-82B4-4204-8529-536626F7E0DF} + Win32Proj + c1p65 + + + + Application + true + v120 + + + + + Application + false + v120 + true + + + + + + + + + + + + + + + true + $(SolutionDir)..\bin\ + $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\bin\ + $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + common + + + Console + true + $(IntDir)..\..\common\$(Configuration)\common.lib + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + common + + + Console + true + true + true + $(IntDir)..\..\common\$(Configuration)\common.lib + + + + + \ No newline at end of file From 29801cd45f4733389c4506195614095c87825df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 2 Nov 2014 23:22:41 +0100 Subject: [PATCH 07/63] Enter bytes in a loop in data mode --- src/c1p65/main.c | 440 ++++++++++++++++++++++++----------------------- 1 file changed, 221 insertions(+), 219 deletions(-) diff --git a/src/c1p65/main.c b/src/c1p65/main.c index c15c77a88..467953c57 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -1,219 +1,221 @@ -/* Object file conversion utility for Challenger 1P - - by Stephan Muehlstrasser -*/ - - -#include -#include -#include -#include -#include -#include - -/* common stuff */ -#include "abend.h" -#include "cmdline.h" -#include "fname.h" -#include "chartype.h" -#include "target.h" -#include "version.h" -#include "xmalloc.h" - -static void Usage (void) -{ - printf ( - "Usage: %s [options] file\n" - "Short options:\n" - " -V\t\t\tPrint the version number\n" - " -h\t\t\tHelp (this text)\n" - " -o name\t\tName the C1P output file (default: )\n" - " -S addr\t\tLoad address (default 0x400)\n" - "\n" - "Long options:\n" - " --help\t\tHelp (this text)\n" - " --version\t\tPrint the version number\n", - ProgName); -} - -static void OptHelp (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print usage information and exit */ -{ - Usage (); - exit (EXIT_SUCCESS); -} - - -static void OptVersion (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print the program version */ -{ - fprintf (stderr, "grc65 V%s\n", GetVersionAsString ()); -} - - -static unsigned long CvtNumber (const char* Arg, const char* Number) -/* Convert a number from a string. Allow '$' and '0x' prefixes for hex - * numbers. Duplicated from ld65's main.c. - */ -{ - unsigned long Val; - int Converted; - - /* Convert */ - if (*Number == '$') { - ++Number; - Converted = sscanf (Number, "%lx", &Val); - } else { - Converted = sscanf (Number, "%li", (long*)&Val); - } - - /* Check if we do really have a number */ - if (Converted != 1) { - AbEnd ("Invalid number given in argument: %s\n", Arg); - } - - /* Return the result */ - return Val; -} - -/* Commands of C1P PROM monitor */ -#define ADDRESS_MODE_CMD '.' -#define DATA_MODE_CMD '/' -#define EXECUTE_CMD 'G' - -/* Transform the cc65 executable binary into a series of - commands that make the C1P PROM monitor load the bytes - into memory. -*/ -static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) -{ - int c; - unsigned long CurrentAddress; - - /* Loop over all input bytes, position to current address, - switch to data mod, output input byte - */ - for (CurrentAddress = StartAddress, c = getc(In); - c != EOF; - c = getc(In), CurrentAddress += 1) { - fprintf (Out, "%c%04.4X%c%02.2X", - ADDRESS_MODE_CMD, (unsigned int) CurrentAddress & 0xFFFF, - DATA_MODE_CMD, (unsigned int) c & 0xFF); - } - - /* And execute - fprintf (Out, "%c%04.4x%c", - ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, - EXECUTE_CMD); - */ -} - -/* Default suffix for C1P object file */ -#define C1P_SUFFIX ".c1p" - -int main (int argc, char *argv[]) -{ - /* Program long options */ - static const LongOpt OptTab[] = { - { "--help", 0, OptHelp}, - { "--version", 0, OptVersion}, - }; - - /* Initialize input and output file name */ - const char* InputFile = 0; - const char* OutputFile = 0; - char *GeneratedOutputFile = 0; - - /* Initialize file pointers */ - FILE *InputFileFp = 0; - FILE *OutputFileFp = 0; - - /* Initialize with default start address defined in c1p.cfg */ - unsigned long StartAddr = 0x400; - - unsigned int I; - - /* Initialize the cmdline module */ - InitCmdLine (&argc, &argv, "c1p65"); - - /* Check the parameters */ - I = 1; - while (I < ArgCount) { - - /* Get the argument */ - const char* Arg = ArgVec [I]; - - /* Check for an option */ - if (Arg[0] == '-') { - switch (Arg[1]) { - - case '-': - LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); - break; - - case 'o': - OutputFile = GetArg (&I, 2); - break; - - case 'S': - StartAddr = CvtNumber (Arg, GetArg (&I, 2)); - break; - - case 'h': - case '?': - OptHelp (Arg, 0); - break; - - case 'V': - OptVersion (Arg, 0); - break; - - default: - UnknownOption (Arg); - } - - } else { - if (InputFile) { - fprintf (stderr, "additional file specs ignored\n"); - } else { - InputFile = Arg; - } - } - - /* Next argument */ - ++I; - } - - if (!InputFile) AbEnd ("No input file"); - - if (!OutputFile) { - const size_t len = strlen(InputFile) + sizeof(C1P_SUFFIX); - - GeneratedOutputFile = (char *) xmalloc(len); - sprintf(GeneratedOutputFile, "%s%s", InputFile, C1P_SUFFIX); - OutputFile = GeneratedOutputFile; - } - - /* Open input and output files */ - InputFileFp = fopen(InputFile, "rb"); - if (!InputFileFp) AbEnd ("Unable to open input file"); - - OutputFileFp = fopen(OutputFile, "wb"); - if (!OutputFileFp) AbEnd ("Unable to open output file"); - - /* Generate object file */ - Transform (StartAddr, InputFileFp, OutputFileFp); - - /* Cleanup */ - if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file"); - - if (fclose(OutputFileFp) == EOF) AbEnd ("Error closing output file"); - - if (GeneratedOutputFile) { - xfree(GeneratedOutputFile); - } - - return EXIT_SUCCESS; -} +/* Object file conversion utility for Challenger 1P + + by Stephan Muehlstrasser +*/ + + +#include +#include +#include +#include +#include +#include + +/* common stuff */ +#include "abend.h" +#include "cmdline.h" +#include "fname.h" +#include "chartype.h" +#include "target.h" +#include "version.h" +#include "xmalloc.h" + +static void Usage (void) +{ + printf ( + "Usage: %s [options] file\n" + "Short options:\n" + " -V\t\t\tPrint the version number\n" + " -h\t\t\tHelp (this text)\n" + " -o name\t\tName the C1P output file (default: )\n" + " -S addr\t\tLoad address (default 0x400)\n" + "\n" + "Long options:\n" + " --help\t\tHelp (this text)\n" + " --version\t\tPrint the version number\n", + ProgName); +} + +static void OptHelp (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Print usage information and exit */ +{ + Usage (); + exit (EXIT_SUCCESS); +} + + +static void OptVersion (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Print the program version */ +{ + fprintf (stderr, "grc65 V%s\n", GetVersionAsString ()); +} + + +static unsigned long CvtNumber (const char* Arg, const char* Number) +/* Convert a number from a string. Allow '$' and '0x' prefixes for hex + * numbers. Duplicated from ld65's main.c. + */ +{ + unsigned long Val; + int Converted; + + /* Convert */ + if (*Number == '$') { + ++Number; + Converted = sscanf (Number, "%lx", &Val); + } else { + Converted = sscanf (Number, "%li", (long*)&Val); + } + + /* Check if we do really have a number */ + if (Converted != 1) { + AbEnd ("Invalid number given in argument: %s\n", Arg); + } + + /* Return the result */ + return Val; +} + +/* Commands of C1P PROM monitor */ +#define ADDRESS_MODE_CMD '.' +#define DATA_MODE_CMD '/' +#define EXECUTE_CMD 'G' +#define DATA_MODE_ADDRESS 0x00FB + +/* Transform the cc65 executable binary into a series of + commands that make the C1P PROM monitor load the bytes + into memory. +*/ +static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) +{ + int c; + + /* Position to the start address */ + fprintf(Out, "%c%04.4X%c", ADDRESS_MODE_CMD, + StartAddress & 0xFFFF, DATA_MODE_CMD); + + /* Loop over all input bytes and enter them one by one */ + for (c = getc(In); c != EOF; c = getc(In)) { + fprintf(Out, "%02.2X\n", (unsigned int) c & 0xFF); + } + + /* Store 00 to 0x00FB to enable keyboard input at the end */ + fprintf(Out, "%c%04.4X%c%02.2X\n", ADDRESS_MODE_CMD, + 0x00FB, DATA_MODE_CMD, 0x00); + + /* And execute + fprintf (Out, "%c%04.4x%c", + ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, + EXECUTE_CMD); + */ +} + +/* Default suffix for C1P object file */ +#define C1P_SUFFIX ".c1p" + +int main (int argc, char *argv[]) +{ + /* Program long options */ + static const LongOpt OptTab[] = { + { "--help", 0, OptHelp}, + { "--version", 0, OptVersion}, + }; + + /* Initialize input and output file name */ + const char* InputFile = 0; + const char* OutputFile = 0; + char *GeneratedOutputFile = 0; + + /* Initialize file pointers */ + FILE *InputFileFp = 0; + FILE *OutputFileFp = 0; + + /* Initialize with default start address defined in c1p.cfg */ + unsigned long StartAddr = 0x400; + + unsigned int I; + + /* Initialize the cmdline module */ + InitCmdLine (&argc, &argv, "c1p65"); + + /* Check the parameters */ + I = 1; + while (I < ArgCount) { + + /* Get the argument */ + const char* Arg = ArgVec [I]; + + /* Check for an option */ + if (Arg[0] == '-') { + switch (Arg[1]) { + + case '-': + LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); + break; + + case 'o': + OutputFile = GetArg (&I, 2); + break; + + case 'S': + StartAddr = CvtNumber (Arg, GetArg (&I, 2)); + break; + + case 'h': + case '?': + OptHelp (Arg, 0); + break; + + case 'V': + OptVersion (Arg, 0); + break; + + default: + UnknownOption (Arg); + } + + } else { + if (InputFile) { + fprintf (stderr, "additional file specs ignored\n"); + } else { + InputFile = Arg; + } + } + + /* Next argument */ + ++I; + } + + if (!InputFile) AbEnd ("No input file"); + + if (!OutputFile) { + const size_t len = strlen(InputFile) + sizeof(C1P_SUFFIX); + + GeneratedOutputFile = (char *) xmalloc(len); + sprintf(GeneratedOutputFile, "%s%s", InputFile, C1P_SUFFIX); + OutputFile = GeneratedOutputFile; + } + + /* Open input and output files */ + InputFileFp = fopen(InputFile, "rb"); + if (!InputFileFp) AbEnd ("Unable to open input file"); + + OutputFileFp = fopen(OutputFile, "wb"); + if (!OutputFileFp) AbEnd ("Unable to open output file"); + + /* Generate object file */ + Transform (StartAddr, InputFileFp, OutputFileFp); + + /* Cleanup */ + if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file"); + + if (fclose(OutputFileFp) == EOF) AbEnd ("Error closing output file"); + + if (GeneratedOutputFile) { + xfree(GeneratedOutputFile); + } + + return EXIT_SUCCESS; +} From 1f85c48fb218e711d1ab1e273ac512d57ac0db34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Thu, 6 Nov 2014 20:46:16 +0100 Subject: [PATCH 08/63] Added the c1p65 project. --- src/cc65.sln | 246 ++++++++++++++++++++++++++------------------------- 1 file changed, 127 insertions(+), 119 deletions(-) diff --git a/src/cc65.sln b/src/cc65.sln index 9d0f2cc2e..3fb7e2a61 100644 --- a/src/cc65.sln +++ b/src/cc65.sln @@ -1,119 +1,127 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{71DC1F68-BFC4-478C-8655-C8E9C9654D2B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cc65", "cc65.vcxproj", "{B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ca65", "ca65.vcxproj", "{D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ar65", "ar65.vcxproj", "{5E8C19C6-B167-440C-8BEF-3CBF109CDB49}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ld65", "ld65.vcxproj", "{26C749A0-814C-47A2-9D36-AE92AE932FE4}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cl65", "cl65.vcxproj", "{F657912F-050A-488B-B203-50ED5715CDD7}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "da65", "da65.vcxproj", "{0BCFB793-2B25-40E2-B265-75848824AC4C}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "co65", "co65.vcxproj", "{F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grc65", "grc65.vcxproj", "{E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "od65", "od65.vcxproj", "{FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sp65", "sp65.vcxproj", "{4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{002A366E-2863-46A8-BDDE-DDF534AAEC73}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.ActiveCfg = Debug|Win32 - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.Build.0 = Debug|Win32 - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.ActiveCfg = Release|Win32 - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.Build.0 = Release|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.ActiveCfg = Debug|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.Build.0 = Debug|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.ActiveCfg = Release|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.Build.0 = Release|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.ActiveCfg = Debug|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.Build.0 = Debug|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.ActiveCfg = Release|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.Build.0 = Release|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.ActiveCfg = Debug|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.Build.0 = Debug|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.ActiveCfg = Release|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.Build.0 = Release|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.ActiveCfg = Debug|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.Build.0 = Debug|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.ActiveCfg = Release|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.Build.0 = Release|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.ActiveCfg = Debug|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.Build.0 = Debug|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.ActiveCfg = Release|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.Build.0 = Release|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.ActiveCfg = Debug|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.Build.0 = Debug|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.ActiveCfg = Release|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.Build.0 = Release|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.ActiveCfg = Debug|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.Build.0 = Debug|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.ActiveCfg = Release|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.Build.0 = Release|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.ActiveCfg = Debug|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.Build.0 = Debug|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.ActiveCfg = Release|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.Build.0 = Release|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.ActiveCfg = Debug|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.Build.0 = Debug|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.ActiveCfg = Release|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.Build.0 = Release|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.ActiveCfg = Debug|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.Build.0 = Debug|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.ActiveCfg = Release|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.Build.0 = Release|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.ActiveCfg = Debug|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.Build.0 = Debug|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.ActiveCfg = Release|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{71DC1F68-BFC4-478C-8655-C8E9C9654D2B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cc65", "cc65.vcxproj", "{B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ca65", "ca65.vcxproj", "{D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ar65", "ar65.vcxproj", "{5E8C19C6-B167-440C-8BEF-3CBF109CDB49}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ld65", "ld65.vcxproj", "{26C749A0-814C-47A2-9D36-AE92AE932FE4}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cl65", "cl65.vcxproj", "{F657912F-050A-488B-B203-50ED5715CDD7}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "da65", "da65.vcxproj", "{0BCFB793-2B25-40E2-B265-75848824AC4C}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "co65", "co65.vcxproj", "{F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grc65", "grc65.vcxproj", "{E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "od65", "od65.vcxproj", "{FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sp65", "sp65.vcxproj", "{4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{002A366E-2863-46A8-BDDE-DDF534AAEC73}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c1p65", "c1p65.vcxproj", "{4E031DE0-82B4-4204-8529-536626F7E0DF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.ActiveCfg = Debug|Win32 + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.Build.0 = Debug|Win32 + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.ActiveCfg = Release|Win32 + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.Build.0 = Release|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.ActiveCfg = Debug|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.Build.0 = Debug|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.ActiveCfg = Release|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.Build.0 = Release|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.ActiveCfg = Debug|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.Build.0 = Debug|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.ActiveCfg = Release|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.Build.0 = Release|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.ActiveCfg = Debug|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.Build.0 = Debug|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.ActiveCfg = Release|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.Build.0 = Release|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.ActiveCfg = Debug|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.Build.0 = Debug|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.ActiveCfg = Release|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.Build.0 = Release|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.ActiveCfg = Debug|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.Build.0 = Debug|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.ActiveCfg = Release|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.Build.0 = Release|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.ActiveCfg = Debug|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.Build.0 = Debug|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.ActiveCfg = Release|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.Build.0 = Release|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.ActiveCfg = Debug|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.Build.0 = Debug|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.ActiveCfg = Release|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.Build.0 = Release|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.ActiveCfg = Debug|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.Build.0 = Debug|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.ActiveCfg = Release|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.Build.0 = Release|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.ActiveCfg = Debug|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.Build.0 = Debug|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.ActiveCfg = Release|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.Build.0 = Release|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.ActiveCfg = Debug|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.Build.0 = Debug|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.ActiveCfg = Release|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.Build.0 = Release|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.ActiveCfg = Debug|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.Build.0 = Debug|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.ActiveCfg = Release|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.Build.0 = Release|Win32 + {4E031DE0-82B4-4204-8529-536626F7E0DF}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E031DE0-82B4-4204-8529-536626F7E0DF}.Debug|Win32.Build.0 = Debug|Win32 + {4E031DE0-82B4-4204-8529-536626F7E0DF}.Release|Win32.ActiveCfg = Release|Win32 + {4E031DE0-82B4-4204-8529-536626F7E0DF}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From 5d7a24241cee19434f1ac8352c7f74eac7b410de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 8 Nov 2014 01:14:46 +0100 Subject: [PATCH 09/63] Implemented clrscr routine for C1P --- libsrc/c1p/c1p.inc | 3 +++ libsrc/c1p/clrscr.s | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 libsrc/c1p/c1p.inc create mode 100644 libsrc/c1p/clrscr.s diff --git a/libsrc/c1p/c1p.inc b/libsrc/c1p/c1p.inc new file mode 100644 index 000000000..525a8e9ee --- /dev/null +++ b/libsrc/c1p/c1p.inc @@ -0,0 +1,3 @@ + +SCRNBASE := $D000 ; Base of video RAM +VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) diff --git a/libsrc/c1p/clrscr.s b/libsrc/c1p/clrscr.s new file mode 100644 index 000000000..f219a4550 --- /dev/null +++ b/libsrc/c1p/clrscr.s @@ -0,0 +1,23 @@ +; +; void clrscr (void); +; + .export _clrscr + .include "c1p.inc" + +; Adapted from the Challenger Character Graphics +; Reference Manual, "2.3.3 MACHINE LANGUAGE SCREEN CLEAR" +; This is self-modifying code! +BANKS = VIDEORAMSIZE / $100 + +_clrscr: LDA #$20 ;' ' + LDY #BANKS + LDX #$00 +STALOC: STA SCRNBASE,X + INX + BNE STALOC + INC STALOC+2 + DEY + BNE STALOC + LDA #>(SCRNBASE) ; load high byte + STA STALOC+2 ; restore base address + RTS From 4c462879286bb8cf1deb46f7868324ee43b505c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 9 Nov 2014 00:58:32 +0100 Subject: [PATCH 10/63] Begin to implement C1P conio features. --- include/c1p.h | 41 +++++++++++++++++++++++++++++++++++++++++ include/conio.h | 2 ++ libsrc/c1p/cgetc.s | 11 +++++++++++ 3 files changed, 54 insertions(+) create mode 100644 include/c1p.h create mode 100644 libsrc/c1p/cgetc.s diff --git a/include/c1p.h b/include/c1p.h new file mode 100644 index 000000000..cea31b0f3 --- /dev/null +++ b/include/c1p.h @@ -0,0 +1,41 @@ +/*****************************************************************************/ +/* */ +/* c1p.h */ +/* */ +/* Challenger 1P system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2014 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 _C1P_H +#define _C1P_H + +/* Check for errors */ +#if !defined(__OSIC1P__) +# error "This module may only be used when compiling for the Challenger 1P!" +#endif + +/* empty for now */ + +#endif diff --git a/include/conio.h b/include/conio.h index 54667a3ca..f59375a63 100644 --- a/include/conio.h +++ b/include/conio.h @@ -77,6 +77,8 @@ # include #elif defined(__NES__) # include +#elif defined(__OSIC1P__) +# include #endif diff --git a/libsrc/c1p/cgetc.s b/libsrc/c1p/cgetc.s new file mode 100644 index 000000000..483c2f2c1 --- /dev/null +++ b/libsrc/c1p/cgetc.s @@ -0,0 +1,11 @@ +; +; char cgetc (void); +; + + .export _cgetc + .include "c1p.inc" + +; Use INPUT routine from 65V PROM MONITOR +_cgetc: + jsr $FEED + rts From 3b379c10e4d0e2ba2dd779adaca2328aa702d5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 15 Nov 2014 20:37:45 +0100 Subject: [PATCH 11/63] Added missing dependency from c1p65 to common --- src/cc65.sln | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65.sln b/src/cc65.sln index 3fb7e2a61..543038755 100644 --- a/src/cc65.sln +++ b/src/cc65.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.30723.0 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{71DC1F68-BFC4-478C-8655-C8E9C9654D2B}" EndProject @@ -61,6 +61,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{ EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c1p65", "c1p65.vcxproj", "{4E031DE0-82B4-4204-8529-536626F7E0DF}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 6edf57324e4e233fa350c74d98263ef1cb4f4309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 16 Nov 2014 20:07:59 +0100 Subject: [PATCH 12/63] Set default start address to 0x300. Make start address configurable via --start-addr. --- cfg/c1p.cfg | 24 +++++++++++++----------- src/c1p65/main.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index f1d739215..d4c248c4f 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -1,9 +1,21 @@ +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + STARTADDRESS: default = $0300; +} SYMBOLS { __STACKSIZE__: type = weak, value = $0400; # 1k stack + __HIMEM__: type = weak, value = $2000; # Presumed RAM end } MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; - RAM: file = %O, define = yes, start = $0400, size = $2000 - __STACKSIZE__; + RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { STARTUP: load = RAM, type = ro; @@ -15,13 +27,3 @@ SEGMENTS { BSS: load = RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; } -FEATURES { - CONDES: type = constructor, - label = __CONSTRUCTOR_TABLE__, - count = __CONSTRUCTOR_COUNT__, - segment = INIT; - CONDES: type = destructor, - label = __DESTRUCTOR_TABLE__, - count = __DESTRUCTOR_COUNT__, - segment = RODATA; -} diff --git a/src/c1p65/main.c b/src/c1p65/main.c index 467953c57..e4358ddcd 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -133,7 +133,7 @@ int main (int argc, char *argv[]) FILE *OutputFileFp = 0; /* Initialize with default start address defined in c1p.cfg */ - unsigned long StartAddr = 0x400; + unsigned long StartAddr = 0x300; unsigned int I; From 14958949c27d38dc69e5e228298d9ad5d9f906e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 16 Nov 2014 21:13:18 +0100 Subject: [PATCH 13/63] Direct use of monitor function instead of subroutine call. --- libsrc/c1p/c1p.inc | 9 +++++++-- libsrc/c1p/cgetc.s | 7 ++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libsrc/c1p/c1p.inc b/libsrc/c1p/c1p.inc index 525a8e9ee..60ea6eaaa 100644 --- a/libsrc/c1p/c1p.inc +++ b/libsrc/c1p/c1p.inc @@ -1,3 +1,8 @@ -SCRNBASE := $D000 ; Base of video RAM -VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) +SCRNBASE := $D000 ; Base of video RAM +VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) + +CURSORPOS := $0200 ; Cursor position for OUTPUTC routine + +OUTPUTC := $BF2D ; Output character at cursor position +INPUTC := $FD00 ; Input character from keyboard diff --git a/libsrc/c1p/cgetc.s b/libsrc/c1p/cgetc.s index 483c2f2c1..a73866a56 100644 --- a/libsrc/c1p/cgetc.s +++ b/libsrc/c1p/cgetc.s @@ -1,11 +1,8 @@ ; ; char cgetc (void); ; - .export _cgetc .include "c1p.inc" -; Use INPUT routine from 65V PROM MONITOR -_cgetc: - jsr $FEED - rts +; Direct use of input routine from 65V PROM MONITOR +_cgetc = INPUTC From a20bba0f1e2abd23b79e920bb1504dfdc44a873c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 16 Nov 2014 21:57:59 +0100 Subject: [PATCH 14/63] Adapt to assembler coding conventions. --- libsrc/c1p/clrscr.s | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libsrc/c1p/clrscr.s b/libsrc/c1p/clrscr.s index f219a4550..5550d1d75 100644 --- a/libsrc/c1p/clrscr.s +++ b/libsrc/c1p/clrscr.s @@ -9,15 +9,17 @@ ; This is self-modifying code! BANKS = VIDEORAMSIZE / $100 -_clrscr: LDA #$20 ;' ' - LDY #BANKS - LDX #$00 -STALOC: STA SCRNBASE,X - INX - BNE STALOC - INC STALOC+2 - DEY - BNE STALOC - LDA #>(SCRNBASE) ; load high byte - STA STALOC+2 ; restore base address - RTS +_clrscr: + lda #$20 ;' ' + ldy #BANKS + ldx #$00 +staloc: + sta SCRNBASE,X + inx + bne staloc + inc staloc+2 + dey + bne staloc + lda #>(SCRNBASE) ; load high byte + sta staloc+2 ; restore base address + rts From d9f764aa07692442ee1d9c92f0e2acd398429be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 18 Nov 2014 23:05:50 +0100 Subject: [PATCH 15/63] Implement macros that shortcut color function calls. --- include/c1p.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/c1p.h b/include/c1p.h index cea31b0f3..5789d7156 100644 --- a/include/c1p.h +++ b/include/c1p.h @@ -36,6 +36,12 @@ # error "This module may only be used when compiling for the Challenger 1P!" #endif -/* empty for now */ +/* 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 From 5c8cd00dd53bec4ce837991704c0a455b4908153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 18 Nov 2014 23:06:28 +0100 Subject: [PATCH 16/63] Started cputc and related functions implementation. --- libsrc/c1p/cputc.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 libsrc/c1p/cputc.c diff --git a/libsrc/c1p/cputc.c b/libsrc/c1p/cputc.c new file mode 100644 index 000000000..0c001cf58 --- /dev/null +++ b/libsrc/c1p/cputc.c @@ -0,0 +1,71 @@ +/* + * cputc.c + * + * void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); + * void __fastcall__ cputc (char c); + */ + +#include + +/* Implements a 25 by 25 screen in the 1024 bytes video ram (32 by 32) */ +#define LINEWIDTH 0x20 +#define SCREENBASE ((char *) 0xd000) +#define TOP_OFFSET 4 +#define LEFT_OFFSET 3 +#define SCREENVISBASE (SCREENBASE + 4 * LINEWIDTH + LEFT_OFFSET) +#define WIDTH 25 +#define HEIGHT 25 + +static unsigned char xpos = 0; +static unsigned char ypos = 0; + +void __fastcall__ cputc(char c) +{ + char * const cp = SCREENVISBASE + ypos * LINEWIDTH + xpos; + + *cp = c; + + xpos += 1; + if (xpos > WIDTH - 1) { + xpos = 0; + ypos += 1; + + if (ypos > HEIGHT - 1) { + ypos = 0; + } + } +} + +void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c) +{ + xpos = x > WIDTH - 1 ? WIDTH - 1 : x; + ypos = y > HEIGHT - 1 ? HEIGHT - 1 : y; + + cputc(c); +} + +unsigned char wherex (void) +{ + return xpos; +} + +unsigned char wherey (void) +{ + return ypos; +} + +void __fastcall__ gotox (unsigned char x) +{ + xpos = x; +} + +void __fastcall__ gotoy (unsigned char y) +{ + ypos = y; +} + +void __fastcall__ gotoxy (unsigned char x, unsigned char y) +{ + xpos = x; + ypos = y; +} From 0a6afb59c08828f64168c1e22c08619d0fbb68ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 22 Nov 2014 01:07:55 +0100 Subject: [PATCH 17/63] Switch to assembler for cputc implementation. --- cfg/c1p.cfg | 3 +- libsrc/c1p/cputc.c | 71 -------------------------- libsrc/c1p/cputc.s | 117 +++++++++++++++++++++++++++++++++++++++++++ libsrc/c1p/extzp.inc | 7 +++ libsrc/c1p/extzp.s | 23 +++++++++ libsrc/c1p/gotoxy.s | 17 +++++++ 6 files changed, 166 insertions(+), 72 deletions(-) delete mode 100644 libsrc/c1p/cputc.c create mode 100644 libsrc/c1p/cputc.s create mode 100644 libsrc/c1p/extzp.inc create mode 100644 libsrc/c1p/extzp.s create mode 100644 libsrc/c1p/gotoxy.s diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index d4c248c4f..46015017b 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -14,7 +14,7 @@ SYMBOLS { __HIMEM__: type = weak, value = $2000; # Presumed RAM end } MEMORY { - ZP: file = "", define = yes, start = $0002, size = $001A; + ZP: file = "", define = yes, start = $0002, size = $001A + $0005; RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { @@ -26,4 +26,5 @@ SEGMENTS { DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = rw, define = yes; } diff --git a/libsrc/c1p/cputc.c b/libsrc/c1p/cputc.c deleted file mode 100644 index 0c001cf58..000000000 --- a/libsrc/c1p/cputc.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * cputc.c - * - * void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); - * void __fastcall__ cputc (char c); - */ - -#include - -/* Implements a 25 by 25 screen in the 1024 bytes video ram (32 by 32) */ -#define LINEWIDTH 0x20 -#define SCREENBASE ((char *) 0xd000) -#define TOP_OFFSET 4 -#define LEFT_OFFSET 3 -#define SCREENVISBASE (SCREENBASE + 4 * LINEWIDTH + LEFT_OFFSET) -#define WIDTH 25 -#define HEIGHT 25 - -static unsigned char xpos = 0; -static unsigned char ypos = 0; - -void __fastcall__ cputc(char c) -{ - char * const cp = SCREENVISBASE + ypos * LINEWIDTH + xpos; - - *cp = c; - - xpos += 1; - if (xpos > WIDTH - 1) { - xpos = 0; - ypos += 1; - - if (ypos > HEIGHT - 1) { - ypos = 0; - } - } -} - -void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c) -{ - xpos = x > WIDTH - 1 ? WIDTH - 1 : x; - ypos = y > HEIGHT - 1 ? HEIGHT - 1 : y; - - cputc(c); -} - -unsigned char wherex (void) -{ - return xpos; -} - -unsigned char wherey (void) -{ - return ypos; -} - -void __fastcall__ gotox (unsigned char x) -{ - xpos = x; -} - -void __fastcall__ gotoy (unsigned char y) -{ - ypos = y; -} - -void __fastcall__ gotoxy (unsigned char x, unsigned char y) -{ - xpos = x; - ypos = y; -} diff --git a/libsrc/c1p/cputc.s b/libsrc/c1p/cputc.s new file mode 100644 index 000000000..192aec097 --- /dev/null +++ b/libsrc/c1p/cputc.s @@ -0,0 +1,117 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .export _cputcxy, _cputc, cputdirect, putchar + .export newline, plot + .import popa, _gotoxy + + .include "c1p.inc" + .include "extzp.inc" + +_cputcxy: + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy ; Set cursor, drop x + 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 + +; Printable char of some sort + +; cmp #' ' +; bcc cputdirect ; Other control char < 0x20 +; tay +; bmi L10 +; cmp #$60 +; bcc L2 +; and #$DF +; bne cputdirect ; Branch always +;L2: and #$3F + +cputdirect: + jsr putchar ; Write the character to the screen + +; Advance cursor position + +advance: + cpy SCR_LINELEN ; xsize-1 + bne L3 + jsr newline ; new line + ldy #$FF ; + cr +L3: iny + sty CURS_X + rts + +newline: + lda SCR_LINELEN ; xsize-1 + sec ; Account for -1 above + adc SCREEN_PTR + sta SCREEN_PTR + bcc L4 + inc SCREEN_PTR+1 +L4: inc CURS_Y + rts + +; Handle character if high bit set + +; L10: and #$7F +; cmp #$7E ; PI? +; bne L11 +; lda #$5E ; Load screen code for PI +; bne cputdirect +; L11: ora #$40 +; bne cputdirect + + + +; Set cursor position, calculate RAM pointers + +plot: ldy CURS_Y + lda ScrLo,y + sta SCREEN_PTR + lda ScrHi,y +; ldy SCR_LINELEN +; cpy #40+1 +; bcc @L1 +; asl SCREEN_PTR ; 80 column mode +; rol a +;@L1: ora #$80 ; Screen at $8000 + sta SCREEN_PTR+1 + rts + + +; Write one character to the screen without doing anything else, return X +; position in Y + +putchar: +; ora RVS ; Set revers bit + ldy CURS_X + sta (SCREEN_PTR),y ; Set char + rts + +; Screen address tables - offset to real screen + +.rodata + +ScrLo: .byte $83, $A3, $C3, $E3, $03, $23, $43, $63 + .byte $83, $A3, $C3, $E3, $03, $23, $43, $63 + .byte $83, $A3, $C3, $E3, $03, $23, $43, $63 + .byte $83 + +ScrHi: .byte $D0, $D0, $D0, $D0, $D1, $D1, $D1, $D1 + .byte $D1, $D1, $D1, $D1, $D2, $D2, $D2, $D2 + .byte $D2, $D2, $D2, $D2, $D3, $D3, $D3, $D3 + .byte $D3 diff --git a/libsrc/c1p/extzp.inc b/libsrc/c1p/extzp.inc new file mode 100644 index 000000000..0f9632df2 --- /dev/null +++ b/libsrc/c1p/extzp.inc @@ -0,0 +1,7 @@ +; +; Additional zero page locations for the Challenger 1P. +; + +; ------------------------------------------------------------------------ + + .globalzp CURS_X, CURS_Y, SCR_LINELEN, SCREEN_PTR diff --git a/libsrc/c1p/extzp.s b/libsrc/c1p/extzp.s new file mode 100644 index 000000000..139feffde --- /dev/null +++ b/libsrc/c1p/extzp.s @@ -0,0 +1,23 @@ +; +; Additional zero page locations for the Challenger 1P. +; NOTE: The zeropage locations contained in this file get initialized +; in the startup code, so if you change anything here, be sure to check +; not only the linker config, but also the startup file. +; + +; ------------------------------------------------------------------------ + + .include "extzp.inc" + +.segment "EXTZP" : zeropage + +; The following values get initialized from a table in the startup code. +; While this sounds crazy, it has reasons that have to do with modules (and +; we have the space anyway). So when changing anything, be sure to adjust the +; initializer table +CURS_X: .byte 0 +CURS_Y: .byte 0 +SCR_LINELEN: .byte 24 +SCREEN_PTR: .res 2 + +; size 5 diff --git a/libsrc/c1p/gotoxy.s b/libsrc/c1p/gotoxy.s new file mode 100644 index 000000000..64c6bd21d --- /dev/null +++ b/libsrc/c1p/gotoxy.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; +; void gotoxy (unsigned char x, unsigned char y); +; + + .export _gotoxy + .import popa, plot + .importzp CURS_X, CURS_Y + +_gotoxy: + sta CURS_Y ; Set Y + jsr popa ; Get X + sta CURS_X ; Set X + jmp plot ; Set the cursor position + + From 12ca22c2654ee5070e699cc15f77bb7888d1dee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 22 Nov 2014 18:14:52 +0100 Subject: [PATCH 18/63] Remove unnecessary commented code. --- libsrc/c1p/cputc.s | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/libsrc/c1p/cputc.s b/libsrc/c1p/cputc.s index 192aec097..35326d04b 100644 --- a/libsrc/c1p/cputc.s +++ b/libsrc/c1p/cputc.s @@ -1,10 +1,10 @@ ; -; Ullrich von Bassewitz, 06.08.1998 +; cputc/cputcxy for Challenger 1P +; Based on PET/CBM implementation ; ; void cputcxy (unsigned char x, unsigned char y, char c); ; void cputc (char c); ; - .export _cputcxy, _cputc, cputdirect, putchar .export newline, plot .import popa, _gotoxy @@ -29,18 +29,6 @@ _cputc: cmp #$0A ; CR? L1: cmp #$0D ; LF? beq newline ; Recalculate pointers -; Printable char of some sort - -; cmp #' ' -; bcc cputdirect ; Other control char < 0x20 -; tay -; bmi L10 -; cmp #$60 -; bcc L2 -; and #$DF -; bne cputdirect ; Branch always -;L2: and #$3F - cputdirect: jsr putchar ; Write the character to the screen @@ -65,39 +53,17 @@ newline: L4: inc CURS_Y rts -; Handle character if high bit set - -; L10: and #$7F -; cmp #$7E ; PI? -; bne L11 -; lda #$5E ; Load screen code for PI -; bne cputdirect -; L11: ora #$40 -; bne cputdirect - - - -; Set cursor position, calculate RAM pointers - plot: ldy CURS_Y lda ScrLo,y sta SCREEN_PTR lda ScrHi,y -; ldy SCR_LINELEN -; cpy #40+1 -; bcc @L1 -; asl SCREEN_PTR ; 80 column mode -; rol a -;@L1: ora #$80 ; Screen at $8000 sta SCREEN_PTR+1 rts - ; Write one character to the screen without doing anything else, return X ; position in Y putchar: -; ora RVS ; Set revers bit ldy CURS_X sta (SCREEN_PTR),y ; Set char rts From 0c62ddf123179f49bddff29e87b161278e76afb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 23 Nov 2014 15:32:48 +0100 Subject: [PATCH 19/63] Enhancements for cursor calculation Fix handling of newlines. Wrap around to top of screen when newline occurs in last line. Initialize screen width in crt0.s. --- libsrc/c1p/cputc.s | 14 ++++++-------- libsrc/c1p/crt0.s | 8 ++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libsrc/c1p/cputc.s b/libsrc/c1p/cputc.s index 35326d04b..ca9152aa7 100644 --- a/libsrc/c1p/cputc.s +++ b/libsrc/c1p/cputc.s @@ -44,14 +44,12 @@ L3: iny rts newline: - lda SCR_LINELEN ; xsize-1 - sec ; Account for -1 above - adc SCREEN_PTR - sta SCREEN_PTR - bcc L4 - inc SCREEN_PTR+1 -L4: inc CURS_Y - rts + inc CURS_Y + lda CURS_Y + cmp #24 ; screen height 25 lines hardcoded + bne plot + lda #0 ; wrap around to line 0 + sta CURS_Y plot: ldy CURS_Y lda ScrLo,y diff --git a/libsrc/c1p/crt0.s b/libsrc/c1p/crt0.s index 97d572608..8f25c2a8d 100644 --- a/libsrc/c1p/crt0.s +++ b/libsrc/c1p/crt0.s @@ -13,6 +13,7 @@ .import zerobss, initlib, donelib .include "zeropage.inc" +.include "extzp.inc" ; --------------------------------------------------------------------------- ; Place the startup code in a special segment @@ -26,6 +27,13 @@ _init: LDX #$FF ; Initialize stack pointer to $01FF TXS CLD ; Clear decimal mode +; --------------------------------------------------------------------------- +; Initialize screen width +; TODO: Can initialization be done in a more idiomatic way? +; TODO: Create function for changing screen width + LDA #$18 + STA SCR_LINELEN + ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer From 1e88032608d5a7da421f1722acbc842a38d132ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 23 Nov 2014 15:56:38 +0100 Subject: [PATCH 20/63] Copied wherex, wherey and ctype implementations from CBM --- libsrc/c1p/ctype.s | 290 ++++++++++++++++++++++++++++++++++++++++++++ libsrc/c1p/wherex.s | 14 +++ libsrc/c1p/wherey.s | 14 +++ 3 files changed, 318 insertions(+) create mode 100644 libsrc/c1p/ctype.s create mode 100644 libsrc/c1p/wherex.s create mode 100644 libsrc/c1p/wherey.s diff --git a/libsrc/c1p/ctype.s b/libsrc/c1p/ctype.s new file mode 100644 index 000000000..dd7ac62c3 --- /dev/null +++ b/libsrc/c1p/ctype.s @@ -0,0 +1,290 @@ +; +; Character specification table. +; +; Ullrich von Bassewitz, 02.06.1998 +; 2003-05-02, Greg King +; +; Copied from cbm/ctype.s + +; The following 256-byte-wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it weren't for the slow parameter-passing of cc65, +; one even could define C-language macroes for the isxxx functions +; (as it usually is done, on other platforms). +; +; * It is highly portable. The only unportable part is the table itself; +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. + +; This table is taken from Craig S. Bruce's technical docs. for the ACE OS. + + .include "ctype.inc" + +; The table is read-only, put it into the RODATA segment. + + .rodata + +__ctype: + .byte CT_CTRL ; 0/00 ___rvs_@___ + .byte CT_CTRL ; 1/01 ___rvs_a___ + .byte CT_CTRL ; 2/02 ___rvs_b___ + .byte CT_CTRL ; 3/03 ___rvs_c___ + .byte CT_CTRL ; 4/04 ___rvs_d___ + .byte CT_CTRL ; 5/05 ___rvs_e___ + .byte CT_CTRL ; 6/06 ___rvs_f___ + .byte CT_CTRL ; 7/07 _BEL/rvs_g_ + .byte CT_CTRL ; 8/08 ___rvs_h___ + .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB ; 9/09 _TAB/rvs_i_ + .byte CT_CTRL | CT_OTHER_WS ; 10/0a _BOL/rvs_j_ + .byte CT_CTRL ; 11/0b ___rvs_k___ + .byte CT_CTRL ; 12/0c ___rvs_l___ + .byte CT_CTRL | CT_OTHER_WS ; 13/0d _CR_/rvs_m_ + .byte CT_CTRL ; 14/0e ___rvs_n___ + .byte CT_CTRL ; 15/0f ___rvs_o___ + .byte CT_CTRL ; 16/10 ___rvs_p___ + .byte CT_CTRL | CT_OTHER_WS ; 17/11 _VT_/rvs_q_ + .byte CT_CTRL ; 18/12 ___rvs_r___ + .byte CT_CTRL | CT_OTHER_WS ; 19/13 HOME/rvs_s_ + .byte CT_CTRL | CT_OTHER_WS ; 20/14 _BS_/rvs_t_ + .byte CT_CTRL ; 21/15 ___rvs_u___ + .byte CT_CTRL ; 22/16 ___rvs_v___ + .byte CT_CTRL ; 23/17 ___rvs_w___ + .byte CT_CTRL ; 24/18 ___rvs_x___ + .byte CT_CTRL ; 25/19 ___rvs_y___ + .byte CT_CTRL ; 26/1a ___rvs_z___ + .byte CT_CTRL ; 27/1b ___rvs_[___ + .byte CT_CTRL ; 28/1c ___rvs_\___ + .byte CT_CTRL | CT_OTHER_WS ; 29/1d cursr-right + .byte CT_CTRL ; 30/1e ___rvs_^___ + .byte CT_CTRL ; 31/1f _rvs_under_ + .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____ + .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____ + .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____ + .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____ + .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____ + .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____ + .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____ + .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____ + .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____ + .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte CT_LOWER | CT_XDIGIT ; 65/41 _____a_____ + .byte CT_LOWER | CT_XDIGIT ; 66/42 _____b_____ + .byte CT_LOWER | CT_XDIGIT ; 67/43 _____c_____ + .byte CT_LOWER | CT_XDIGIT ; 68/44 _____d_____ + .byte CT_LOWER | CT_XDIGIT ; 69/45 _____e_____ + .byte CT_LOWER | CT_XDIGIT ; 70/46 _____f_____ + .byte CT_LOWER ; 71/47 _____g_____ + .byte CT_LOWER ; 72/48 _____h_____ + .byte CT_LOWER ; 73/49 _____i_____ + .byte CT_LOWER ; 74/4a _____j_____ + .byte CT_LOWER ; 75/4b _____k_____ + .byte CT_LOWER ; 76/4c _____l_____ + .byte CT_LOWER ; 77/4d _____m_____ + .byte CT_LOWER ; 78/4e _____n_____ + .byte CT_LOWER ; 79/4f _____o_____ + .byte CT_LOWER ; 80/50 _____p_____ + .byte CT_LOWER ; 81/51 _____q_____ + .byte CT_LOWER ; 82/52 _____r_____ + .byte CT_LOWER ; 83/53 _____s_____ + .byte CT_LOWER ; 84/54 _____t_____ + .byte CT_LOWER ; 85/55 _____u_____ + .byte CT_LOWER ; 86/56 _____v_____ + .byte CT_LOWER ; 87/57 _____w_____ + .byte CT_LOWER ; 88/58 _____x_____ + .byte CT_LOWER ; 89/59 _____y_____ + .byte CT_LOWER ; 90/5a _____z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 _A`_grave__ + .byte $00 ; 97/61 _A'_acute__ + .byte $00 ; 98/62 _A^_circum_ + .byte $00 ; 99/63 _A~_tilde__ + .byte $00 ; 100/64 _A"_dieres_ + .byte $00 ; 101/65 _A__ring___ + .byte $00 ; 102/66 _AE________ + .byte $00 ; 103/67 _C,cedilla_ + .byte $00 ; 104/68 _E`_grave__ + .byte $00 ; 105/69 _E'_acute__ + .byte $00 ; 106/6a _E^_circum_ + .byte $00 ; 107/6b _E"_dieres_ + .byte $00 ; 108/6c _I`_grave__ + .byte $00 ; 109/6d _I'_acute__ + .byte $00 ; 110/6e _I^_circum_ + .byte $00 ; 111/6f _I"_dieres_ + .byte $00 ; 112/70 _D-_Eth_lr_ + .byte $00 ; 113/71 _N~_tilde__ + .byte $00 ; 114/72 _O`_grave__ + .byte $00 ; 115/73 _O'_acute__ + .byte $00 ; 116/74 _O^_circum_ + .byte $00 ; 117/75 _O~_tilde__ + .byte $00 ; 118/76 _O"_dieres_ + .byte $00 ; 119/77 __multiply_ + .byte $00 ; 120/78 _O/_slash__ + .byte $00 ; 121/79 _U`_grave__ + .byte $00 ; 122/7a _U'_acute__ + .byte $00 ; 123/7b _U^_circum_ + .byte $00 ; 124/7c _U"_dieres_ + .byte $00 ; 125/7d _Y'_acute__ + .byte $00 ; 126/7e _cap_thorn_ + .byte $00 ; 127/7f _Es-sed_B__ + + .byte CT_CTRL ; 128/80 __bullet___ + .byte CT_CTRL ; 129/81 __v_line___ + .byte CT_CTRL ; 130/82 __h_line___ + .byte CT_CTRL ; 131/83 ___cross___ + .byte CT_CTRL ; 132/84 _tl_corner_ + .byte CT_CTRL ; 133/85 _tr_corner_ + .byte CT_CTRL ; 134/86 _bl_corner_ + .byte CT_CTRL ; 135/87 _br_corner_ + .byte CT_CTRL ; 136/88 ___l_tee___ + .byte CT_CTRL ; 137/89 ___r_tee___ + .byte CT_CTRL ; 138/8a ___t_tee___ + .byte CT_CTRL ; 139/8b ___b_tee___ + .byte CT_CTRL ; 140/8c ___heart___ + .byte CT_CTRL | CT_OTHER_WS ; 141/8d _CR/diamond + .byte CT_CTRL ; 142/8e ___club____ + .byte CT_CTRL ; 143/8f ___spade___ + .byte CT_CTRL ; 144/90 _s_circle__ + .byte CT_CTRL | CT_OTHER_WS ; 145/91 _cursor-up_ + .byte CT_CTRL ; 146/92 ___pound___ + .byte CT_CTRL | CT_OTHER_WS ; 147/93 _CLS/check_ + .byte CT_CTRL | CT_OTHER_WS ; 148/94 __INSert___ + .byte CT_CTRL ; 149/95 ____+/-____ + .byte CT_CTRL ; 150/96 __divide___ + .byte CT_CTRL ; 151/97 __degree___ + .byte CT_CTRL ; 152/98 _c_checker_ + .byte CT_CTRL ; 153/99 _f_checker_ + .byte CT_CTRL ; 154/9a _solid_sq__ + .byte CT_CTRL ; 155/9b __cr_char__ + .byte CT_CTRL ; 156/9c _up_arrow__ + .byte CT_CTRL | CT_OTHER_WS ; 157/9d cursor-left + .byte CT_CTRL ; 158/9e _left_arro_ + .byte CT_CTRL ; 159/9f _right_arr_ + .byte CT_SPACE | CT_SPACE_TAB ; 160/a0 _req space_ + .byte $00 ; 161/a1 _!_invertd_ + .byte $00 ; 162/a2 ___cent____ + .byte $00 ; 163/a3 ___pound___ + .byte $00 ; 164/a4 __currency_ + .byte $00 ; 165/a5 ____yen____ + .byte $00 ; 166/a6 _|_broken__ + .byte $00 ; 167/a7 __section__ + .byte $00 ; 168/a8 __umulaut__ + .byte $00 ; 169/a9 _copyright_ + .byte $00 ; 170/aa __fem_ord__ + .byte $00 ; 171/ab _l_ang_quo_ + .byte $00 ; 172/ac ____not____ + .byte $00 ; 173/ad _syl_hyphn_ + .byte $00 ; 174/ae _registerd_ + .byte $00 ; 175/af _overline__ + .byte $00 ; 176/b0 __degrees__ + .byte $00 ; 177/b1 ____+/-____ + .byte $00 ; 178/b2 _2_supersc_ + .byte $00 ; 179/b3 _3_supersc_ + .byte $00 ; 180/b4 ___acute___ + .byte $00 ; 181/b5 ____mu_____ + .byte $00 ; 182/b6 _paragraph_ + .byte $00 ; 183/b7 __mid_dot__ + .byte $00 ; 184/b8 __cedilla__ + .byte $00 ; 185/b9 _1_supersc_ + .byte $00 ; 186/ba __mas_ord__ + .byte $00 ; 187/bb _r_ang_quo_ + .byte $00 ; 188/bc ____1/4____ + .byte $00 ; 189/bd ____1/2____ + .byte $00 ; 190/be ____3/4____ + .byte $00 ; 191/bf _?_invertd_ + + .byte $00 ; 192/c0 _____`_____ + .byte CT_UPPER | CT_XDIGIT ; 193/c1 _____A_____ + .byte CT_UPPER | CT_XDIGIT ; 194/c2 _____B_____ + .byte CT_UPPER | CT_XDIGIT ; 195/c3 _____C_____ + .byte CT_UPPER | CT_XDIGIT ; 196/c4 _____D_____ + .byte CT_UPPER | CT_XDIGIT ; 197/c5 _____E_____ + .byte CT_UPPER | CT_XDIGIT ; 198/c6 _____F_____ + .byte CT_UPPER ; 199/c7 _____G_____ + .byte CT_UPPER ; 200/c8 _____H_____ + .byte CT_UPPER ; 201/c9 _____I_____ + .byte CT_UPPER ; 202/ca _____J_____ + .byte CT_UPPER ; 203/cb _____K_____ + .byte CT_UPPER ; 204/cc _____L_____ + .byte CT_UPPER ; 205/cd _____M_____ + .byte CT_UPPER ; 206/ce _____N_____ + .byte CT_UPPER ; 207/cf _____O_____ + .byte CT_UPPER ; 208/d0 _____P_____ + .byte CT_UPPER ; 209/d1 _____Q_____ + .byte CT_UPPER ; 210/d2 _____R_____ + .byte CT_UPPER ; 211/d3 _____S_____ + .byte CT_UPPER ; 212/d4 _____T_____ + .byte CT_UPPER ; 213/d5 _____U_____ + .byte CT_UPPER ; 214/d6 _____V_____ + .byte CT_UPPER ; 215/d7 _____W_____ + .byte CT_UPPER ; 216/d8 _____X_____ + .byte CT_UPPER ; 217/d9 _____Y_____ + .byte CT_UPPER ; 218/da _____Z_____ + .byte $00 ; 219/db _____{_____ + .byte $00 ; 220/dc _____|_____ + .byte $00 ; 221/dd _____}_____ + .byte $00 ; 222/de _____~_____ + .byte $00 ; 223/df ___HOUSE___ + .byte $00 ; 224/e0 _a`_grave__ + .byte $00 ; 225/e1 _a'_acute__ + .byte $00 ; 226/e2 _a^_circum_ + .byte $00 ; 227/e3 _a~_tilde__ + .byte $00 ; 228/e4 _a"_dieres_ + .byte $00 ; 229/e5 _a__ring___ + .byte $00 ; 230/e6 _ae________ + .byte $00 ; 231/e7 _c,cedilla_ + .byte $00 ; 232/e8 _e`_grave__ + .byte $00 ; 233/e9 _e'_acute__ + .byte $00 ; 234/ea _e^_circum_ + .byte $00 ; 235/eb _e"_dieres_ + .byte $00 ; 236/ec _i`_grave__ + .byte $00 ; 237/ed _i'_acute__ + .byte $00 ; 238/ee _i^_circum_ + .byte $00 ; 239/ef _i"_dieres_ + .byte $00 ; 240/f0 _o^x_Eth_s_ + .byte $00 ; 241/f1 _n~_tilda__ + .byte $00 ; 242/f2 _o`_grave__ + .byte $00 ; 243/f3 _o'_acute__ + .byte $00 ; 244/f4 _o^_circum_ + .byte $00 ; 245/f5 _o~_tilde__ + .byte $00 ; 246/f6 _o"_dieres_ + .byte $00 ; 247/f7 __divide___ + .byte $00 ; 248/f8 _o/_slash__ + .byte $00 ; 249/f9 _u`_grave__ + .byte $00 ; 250/fa _u'_acute__ + .byte $00 ; 251/fb _u^_circum_ + .byte $00 ; 252/fc _u"_dieres_ + .byte $00 ; 253/fd _y'_acute__ + .byte $00 ; 254/fe _sm_thorn__ + .byte $00 ; 255/ff _y"_dieres_ + diff --git a/libsrc/c1p/wherex.s b/libsrc/c1p/wherex.s new file mode 100644 index 000000000..7c772a5a2 --- /dev/null +++ b/libsrc/c1p/wherex.s @@ -0,0 +1,14 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; Copied from cbm/wherex.s + +; unsigned char wherex (void); +; + .export _wherex + .import CURS_X: zp + +.proc _wherex + lda CURS_X + ldx #$00 + rts +.endproc diff --git a/libsrc/c1p/wherey.s b/libsrc/c1p/wherey.s new file mode 100644 index 000000000..7449c1ceb --- /dev/null +++ b/libsrc/c1p/wherey.s @@ -0,0 +1,14 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; Copied from cbm/wherey.s +; +; unsigned char wherey (void); +; + .export _wherey + .import CURS_Y: zp + +.proc _wherey + lda CURS_Y + ldx #$00 + rts +.endproc From 1c028c794a86116e9b0a740eaca11fdfb9e5602f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 23 Nov 2014 19:43:24 +0100 Subject: [PATCH 21/63] Clarify help for -o option --- src/c1p65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c1p65/main.c b/src/c1p65/main.c index e4358ddcd..d5e813a3f 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -27,7 +27,7 @@ static void Usage (void) "Short options:\n" " -V\t\t\tPrint the version number\n" " -h\t\t\tHelp (this text)\n" - " -o name\t\tName the C1P output file (default: )\n" + " -o name\t\tName the C1P output file (default: .c1p)\n" " -S addr\t\tLoad address (default 0x400)\n" "\n" "Long options:\n" From dfbd2912ccf6cb56c361470d9b7ef7724790c0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 23 Nov 2014 19:44:45 +0100 Subject: [PATCH 22/63] Fix help text for default start address --- src/c1p65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c1p65/main.c b/src/c1p65/main.c index d5e813a3f..50edcde88 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -28,7 +28,7 @@ static void Usage (void) " -V\t\t\tPrint the version number\n" " -h\t\t\tHelp (this text)\n" " -o name\t\tName the C1P output file (default: .c1p)\n" - " -S addr\t\tLoad address (default 0x400)\n" + " -S addr\t\tLoad address (default 0x300)\n" "\n" "Long options:\n" " --help\t\tHelp (this text)\n" From 16bdb10bfe57f3d9d887e0203f0b514636b035d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 23 Nov 2014 20:05:38 +0100 Subject: [PATCH 23/63] Default is now automatic execution of program after loading --- src/c1p65/main.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/c1p65/main.c b/src/c1p65/main.c index 50edcde88..5edc525eb 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -27,6 +27,7 @@ static void Usage (void) "Short options:\n" " -V\t\t\tPrint the version number\n" " -h\t\t\tHelp (this text)\n" + " -n\t\tNo automatic start after loading program\n" " -o name\t\tName the C1P output file (default: .c1p)\n" " -S addr\t\tLoad address (default 0x300)\n" "\n" @@ -79,16 +80,17 @@ static unsigned long CvtNumber (const char* Arg, const char* Number) } /* Commands of C1P PROM monitor */ -#define ADDRESS_MODE_CMD '.' -#define DATA_MODE_CMD '/' -#define EXECUTE_CMD 'G' +#define ADDRESS_MODE_CMD '.' +#define DATA_MODE_CMD '/' +#define EXECUTE_CMD 'G' #define DATA_MODE_ADDRESS 0x00FB /* Transform the cc65 executable binary into a series of commands that make the C1P PROM monitor load the bytes into memory. */ -static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) +static void Transform (unsigned long StartAddress, FILE *In, FILE *Out, + unsigned AutoStart) { int c; @@ -101,15 +103,17 @@ static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) fprintf(Out, "%02.2X\n", (unsigned int) c & 0xFF); } - /* Store 00 to 0x00FB to enable keyboard input at the end */ - fprintf(Out, "%c%04.4X%c%02.2X\n", ADDRESS_MODE_CMD, - 0x00FB, DATA_MODE_CMD, 0x00); - - /* And execute - fprintf (Out, "%c%04.4x%c", + if (AutoStart) { + /* Execute */ + fprintf (Out, "%c%04.4x%c", ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, EXECUTE_CMD); - */ + } + else { + /* Store 00 to 0x00FB to enable keyboard input at the end */ + fprintf(Out, "%c%04.4X%c%02.2X\n", ADDRESS_MODE_CMD, + 0x00FB, DATA_MODE_CMD, 0x00); + } } /* Default suffix for C1P object file */ @@ -135,6 +139,9 @@ int main (int argc, char *argv[]) /* Initialize with default start address defined in c1p.cfg */ unsigned long StartAddr = 0x300; + /* Start program automatically after loading */ + unsigned AutoStart = 1; + unsigned int I; /* Initialize the cmdline module */ @@ -155,11 +162,15 @@ int main (int argc, char *argv[]) LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); break; - case 'o': - OutputFile = GetArg (&I, 2); - break; + case 'n': + AutoStart = 0; + break; - case 'S': + case 'o': + OutputFile = GetArg(&I, 2); + break; + + case 'S': StartAddr = CvtNumber (Arg, GetArg (&I, 2)); break; @@ -206,7 +217,7 @@ int main (int argc, char *argv[]) if (!OutputFileFp) AbEnd ("Unable to open output file"); /* Generate object file */ - Transform (StartAddr, InputFileFp, OutputFileFp); + Transform (StartAddr, InputFileFp, OutputFileFp, AutoStart); /* Cleanup */ if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file"); From a66c93c55bbe60bb43513ecf5ddbfa8eee5b8a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Wed, 26 Nov 2014 19:01:15 +0100 Subject: [PATCH 24/63] Use CR instead of LF, because this works better over the serial port of a real C1P. --- src/c1p65/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c1p65/main.c b/src/c1p65/main.c index 5edc525eb..3d6cdbe8b 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -100,7 +100,7 @@ static void Transform (unsigned long StartAddress, FILE *In, FILE *Out, /* Loop over all input bytes and enter them one by one */ for (c = getc(In); c != EOF; c = getc(In)) { - fprintf(Out, "%02.2X\n", (unsigned int) c & 0xFF); + fprintf(Out, "%02.2X\r", (unsigned int) c & 0xFF); } if (AutoStart) { @@ -111,7 +111,7 @@ static void Transform (unsigned long StartAddress, FILE *In, FILE *Out, } else { /* Store 00 to 0x00FB to enable keyboard input at the end */ - fprintf(Out, "%c%04.4X%c%02.2X\n", ADDRESS_MODE_CMD, + fprintf(Out, "%c%04.4X%c%02.2X", ADDRESS_MODE_CMD, 0x00FB, DATA_MODE_CMD, 0x00); } } From 7dac57f60d46a06c8cb26f4e6fb625880ab44a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 29 Nov 2014 15:52:42 +0100 Subject: [PATCH 25/63] Added gotox() and gotoy() implementations. --- libsrc/c1p/gotox.s | 17 +++++++++++++++++ libsrc/c1p/gotoy.s | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 libsrc/c1p/gotox.s create mode 100644 libsrc/c1p/gotoy.s diff --git a/libsrc/c1p/gotox.s b/libsrc/c1p/gotox.s new file mode 100644 index 000000000..315e1b5ee --- /dev/null +++ b/libsrc/c1p/gotox.s @@ -0,0 +1,17 @@ +; +; copied from CBM implementation +; originally by: +; Ullrich von Bassewitz, 07.08.1998 +; +; void gotox (unsigned char x); +; + + .export _gotox + .import plot + .importzp CURS_X + +_gotox: sta CURS_X ; Set new position + jmp plot ; And activate it + + + diff --git a/libsrc/c1p/gotoy.s b/libsrc/c1p/gotoy.s new file mode 100644 index 000000000..e9e81451a --- /dev/null +++ b/libsrc/c1p/gotoy.s @@ -0,0 +1,15 @@ +; +; copied from CBM implementation +; originally by: +; Ullrich von Bassewitz, 0.08.1998 +; +; void gotoy (unsigned char y); +; + + .export _gotoy + .import plot + .importzp CURS_Y + +_gotoy: sta CURS_Y ; Set the new position + jmp plot ; And activate it + From ac88639f4a9bdcb40388d6afd04dae032f74b951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 29 Nov 2014 20:07:30 +0100 Subject: [PATCH 26/63] Implemented cursor functionality. --- cfg/c1p.cfg | 3 ++- libsrc/c1p/cgetc.s | 27 ++++++++++++++++++++++++--- libsrc/c1p/extzp.inc | 2 +- libsrc/c1p/extzp.s | 8 +++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index 46015017b..2f48dd084 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -14,7 +14,8 @@ SYMBOLS { __HIMEM__: type = weak, value = $2000; # Presumed RAM end } MEMORY { - ZP: file = "", define = yes, start = $0002, size = $001A + $0005; + # for size of ZP see runtime/zeropage.s and c1p/extzp.s + ZP: file = "", define = yes, start = $0002, size = $001A + $0006; RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { diff --git a/libsrc/c1p/cgetc.s b/libsrc/c1p/cgetc.s index a73866a56..b17e76572 100644 --- a/libsrc/c1p/cgetc.s +++ b/libsrc/c1p/cgetc.s @@ -2,7 +2,28 @@ ; char cgetc (void); ; .export _cgetc - .include "c1p.inc" + .import cursor -; Direct use of input routine from 65V PROM MONITOR -_cgetc = INPUTC + .include "c1p.inc" + .include "extzp.inc" + +; Input routine from 65V PROM MONITOR, show cursor if enabled +_cgetc: + lda cursor ; show cursor? + beq nocursor + ldy CURS_X + lda (SCREEN_PTR),y ; fetch current character + sta CURS_SAV ; save it + lda #$A1 ; full white square + sta (SCREEN_PTR),y ; store at cursor position +nocursor: + jsr INPUTC + pha ; save retrieved character + lda cursor ; was cursor on? + beq nocursor2 + lda CURS_SAV ; fetch saved character + ldy CURS_X + sta (SCREEN_PTR),y ; store at cursor position +nocursor2: + pla ; restore retrieved character + rts diff --git a/libsrc/c1p/extzp.inc b/libsrc/c1p/extzp.inc index 0f9632df2..c5bb2b585 100644 --- a/libsrc/c1p/extzp.inc +++ b/libsrc/c1p/extzp.inc @@ -4,4 +4,4 @@ ; ------------------------------------------------------------------------ - .globalzp CURS_X, CURS_Y, SCR_LINELEN, SCREEN_PTR + .globalzp CURS_X, CURS_Y, CURS_SAV, SCR_LINELEN, SCREEN_PTR diff --git a/libsrc/c1p/extzp.s b/libsrc/c1p/extzp.s index 139feffde..c55156f82 100644 --- a/libsrc/c1p/extzp.s +++ b/libsrc/c1p/extzp.s @@ -11,13 +11,11 @@ .segment "EXTZP" : zeropage -; The following values get initialized from a table in the startup code. -; While this sounds crazy, it has reasons that have to do with modules (and -; we have the space anyway). So when changing anything, be sure to adjust the -; initializer table CURS_X: .byte 0 CURS_Y: .byte 0 +CURS_SAV: .byte 0 SCR_LINELEN: .byte 24 SCREEN_PTR: .res 2 -; size 5 +; size 6 +; Adjust size of this segment in c1p.cfg if the size changes From 6dc8621fa537901bc9b19731ab3cb70780ff71b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 29 Nov 2014 20:50:48 +0100 Subject: [PATCH 27/63] Set cursor in top left corner in clrscr() as documented in conio.h --- libsrc/c1p/clrscr.s | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libsrc/c1p/clrscr.s b/libsrc/c1p/clrscr.s index 5550d1d75..ce221f31e 100644 --- a/libsrc/c1p/clrscr.s +++ b/libsrc/c1p/clrscr.s @@ -2,6 +2,8 @@ ; void clrscr (void); ; .export _clrscr + .import plot + .importzp CURS_X, CURS_Y .include "c1p.inc" ; Adapted from the Challenger Character Graphics @@ -10,16 +12,20 @@ BANKS = VIDEORAMSIZE / $100 _clrscr: - lda #$20 ;' ' - ldy #BANKS - ldx #$00 + lda #$20 ;' ' + ldy #BANKS + ldx #$00 staloc: - sta SCRNBASE,X + sta SCRNBASE,X inx - bne staloc - inc staloc+2 + bne staloc + inc staloc+2 dey - bne staloc - lda #>(SCRNBASE) ; load high byte - sta staloc+2 ; restore base address - rts + bne staloc + lda #>(SCRNBASE); load high byte + sta staloc+2 ; restore base address + + lda #$00 ; cursor in upper left corner + sta CURS_X + sta CURS_Y + jmp plot ; Set the cursor position From 67707f342df65cdf0c03d6b24169a80430dcb53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 29 Nov 2014 20:56:49 +0100 Subject: [PATCH 28/63] Set default start address to 0x200 --- cfg/c1p.cfg | 2 +- src/c1p65/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index 2f48dd084..32be486d5 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -7,7 +7,7 @@ FEATURES { label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__, segment = RODATA; - STARTADDRESS: default = $0300; + STARTADDRESS: default = $0200; } SYMBOLS { __STACKSIZE__: type = weak, value = $0400; # 1k stack diff --git a/src/c1p65/main.c b/src/c1p65/main.c index 3d6cdbe8b..bf74f73c1 100644 --- a/src/c1p65/main.c +++ b/src/c1p65/main.c @@ -137,7 +137,7 @@ int main (int argc, char *argv[]) FILE *OutputFileFp = 0; /* Initialize with default start address defined in c1p.cfg */ - unsigned long StartAddr = 0x300; + unsigned long StartAddr = 0x200; /* Start program automatically after loading */ unsigned AutoStart = 1; From 9b9622d09a081aabe0dfd5a8414a7f3bfa799def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 29 Nov 2014 22:13:07 +0100 Subject: [PATCH 29/63] Added chline and cvline implementation from CBM implementation. --- libsrc/c1p/chline.s | 29 +++++++++++++++++++++++++++++ libsrc/c1p/cvline.s | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 libsrc/c1p/chline.s create mode 100644 libsrc/c1p/cvline.s diff --git a/libsrc/c1p/chline.s b/libsrc/c1p/chline.s new file mode 100644 index 000000000..da07e83be --- /dev/null +++ b/libsrc/c1p/chline.s @@ -0,0 +1,29 @@ +; +; based on CBM implementation +; +; originally by: +; Ullrich von Bassewitz, 08.08.1998 +; +; void chlinexy (unsigned char x, unsigned char y, unsigned char length); +; void chline (unsigned char length); +; + + .export _chlinexy, _chline + .import popa, _gotoxy, cputdirect + .importzp tmp1 + +_chlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length + +_chline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #$94 ; Horizontal line, screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts diff --git a/libsrc/c1p/cvline.s b/libsrc/c1p/cvline.s new file mode 100644 index 000000000..607a4c691 --- /dev/null +++ b/libsrc/c1p/cvline.s @@ -0,0 +1,32 @@ +; +; based on CBM version +; originally by: +; Ullrich von Bassewitz, 08.08.1998 +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export _cvlinexy, _cvline + .import popa, _gotoxy, putchar, newline + .importzp tmp1 + +_cvlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_cvline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #$95 ; Vertical bar + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp1 + bne L1 +L9: rts + + + From 3867be716647021a4a3eac6f9a723ad5de131c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 30 Nov 2014 14:25:16 +0100 Subject: [PATCH 30/63] Added cclear() and cclearxy() implementations. --- libsrc/c1p/cclear.s | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libsrc/c1p/cclear.s diff --git a/libsrc/c1p/cclear.s b/libsrc/c1p/cclear.s new file mode 100644 index 000000000..4412f0bba --- /dev/null +++ b/libsrc/c1p/cclear.s @@ -0,0 +1,33 @@ +; +; Copied from CBM implementation +; +; originally by: +; Ullrich von Bassewitz, 08.08.1998 +; +; void cclearxy (unsigned char x, unsigned char y, unsigned char length); +; void cclear (unsigned char length); +; + + .export _cclearxy, _cclear + .import popa, _gotoxy, cputdirect + .importzp tmp1 + +_cclearxy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cclear + +_cclear: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #$20 ; Blank - screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts + + + + From fa770bada8bd88fcae0ef9cbd8494b23a9debd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 30 Nov 2014 15:58:59 +0100 Subject: [PATCH 31/63] Added scrsize() function. --- libsrc/conio/{scrsize.s => _scrsize.s} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libsrc/conio/{scrsize.s => _scrsize.s} (100%) diff --git a/libsrc/conio/scrsize.s b/libsrc/conio/_scrsize.s similarity index 100% rename from libsrc/conio/scrsize.s rename to libsrc/conio/_scrsize.s From 945ad167dfa5d4714e235cdff1458a12e43384af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 30 Nov 2014 16:00:55 +0100 Subject: [PATCH 32/63] Undo accidental rename of wrong scrsize.s file. --- libsrc/conio/{_scrsize.s => scrsize.s} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libsrc/conio/{_scrsize.s => scrsize.s} (100%) diff --git a/libsrc/conio/_scrsize.s b/libsrc/conio/scrsize.s similarity index 100% rename from libsrc/conio/_scrsize.s rename to libsrc/conio/scrsize.s From b47a1d99ece5bb7ff5322f69cd6befed6c657057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 30 Nov 2014 16:01:43 +0100 Subject: [PATCH 33/63] Added scrsize() function. --- libsrc/c1p/_scrsize.s | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 libsrc/c1p/_scrsize.s diff --git a/libsrc/c1p/_scrsize.s b/libsrc/c1p/_scrsize.s new file mode 100644 index 000000000..75de2b349 --- /dev/null +++ b/libsrc/c1p/_scrsize.s @@ -0,0 +1,22 @@ +; +; based on PET implementation +; +; originally by: +; Ullrich von Bassewitz, 26.10.2000 +; +; Screen size variables +; + + .export screensize + + .include "extzp.inc" + +.proc screensize + + ldx SCR_LINELEN + inx ; Variable is one less + ldy #25 + rts + +.endproc + From e9a90940b18f97af5ca6b0db131982019f1c70a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 30 Nov 2014 21:05:36 +0100 Subject: [PATCH 34/63] Dummy implementation for osmapperrno Copied from atmos implementation --- libsrc/c1p/oserror.s | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libsrc/c1p/oserror.s diff --git a/libsrc/c1p/oserror.s b/libsrc/c1p/oserror.s new file mode 100644 index 000000000..073691a06 --- /dev/null +++ b/libsrc/c1p/oserror.s @@ -0,0 +1,20 @@ +; +; dummy implementation for Challenger 1P based on atmos implementation +; +; original by +; Stefan Haubenthal, 2011-04-18 +; +; int __fastcall__ _osmaperrno (unsigned char oserror); +; /* Map a system specific error into a system independent code */ +; + + .include "errno.inc" + .export __osmaperrno + +.proc __osmaperrno + + lda #EUNKNOWN + rts + +.endproc From fd5dca08fb3e3db974075f7932f822b687499f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 2 Dec 2014 18:20:54 +0100 Subject: [PATCH 35/63] Removed unused constants They were left-overs from early attempts to implement character output. --- libsrc/c1p/c1p.inc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libsrc/c1p/c1p.inc b/libsrc/c1p/c1p.inc index 60ea6eaaa..ad058373a 100644 --- a/libsrc/c1p/c1p.inc +++ b/libsrc/c1p/c1p.inc @@ -1,8 +1,4 @@ SCRNBASE := $D000 ; Base of video RAM VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) - -CURSORPOS := $0200 ; Cursor position for OUTPUTC routine - -OUTPUTC := $BF2D ; Output character at cursor position INPUTC := $FD00 ; Input character from keyboard From 8fa5fc61086a8d736b431b8562ec64a2318cec0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Fri, 2 Jan 2015 20:28:36 +0100 Subject: [PATCH 36/63] Restructured according to coding conventions. --- cfg/c1p.cfg | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index 32be486d5..62adcd820 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -1,14 +1,7 @@ FEATURES { - CONDES: type = constructor, - label = __CONSTRUCTOR_TABLE__, - count = __CONSTRUCTOR_COUNT__, - segment = INIT; - CONDES: type = destructor, - label = __DESTRUCTOR_TABLE__, - count = __DESTRUCTOR_COUNT__, - segment = RODATA; STARTADDRESS: default = $0200; } + SYMBOLS { __STACKSIZE__: type = weak, value = $0400; # 1k stack __HIMEM__: type = weak, value = $2000; # Presumed RAM end @@ -29,3 +22,13 @@ SEGMENTS { ZEROPAGE: load = ZP, type = zp; EXTZP: load = ZP, type = rw, define = yes; } +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; +} From 073b4c264aa4bd22deeaed7b97b990bd51fbd8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Mon, 5 Jan 2015 20:37:23 +0100 Subject: [PATCH 37/63] Set default RAM size to 32 kB. 8 kB RAM are very small for "interesting" programs compiled with cc65. Therefore set the default RAM size to 32 kB. --- cfg/c1p.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index 62adcd820..633298270 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -3,8 +3,8 @@ FEATURES { } SYMBOLS { - __STACKSIZE__: type = weak, value = $0400; # 1k stack - __HIMEM__: type = weak, value = $2000; # Presumed RAM end + __STACKSIZE__: type = weak, value = $0400; # 1 kB stack + __HIMEM__: type = weak, value = $8000; # 32 kB RAM } MEMORY { # for size of ZP see runtime/zeropage.s and c1p/extzp.s From 50164a9d68d67bac475460c54c633cc61a4515f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Mon, 5 Jan 2015 20:55:45 +0100 Subject: [PATCH 38/63] Removed c1p65 object file converter. Now using srec_cat from the srecord package. --- src/Makefile | 1 - src/c1p65/main.c | 232 ------------------------------------------- src/cc65.sln | 249 ++++++++++++++++++++++------------------------- 3 files changed, 119 insertions(+), 363 deletions(-) delete mode 100644 src/c1p65/main.c diff --git a/src/Makefile b/src/Makefile index 34706fab5..5aafc4bb8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,7 +3,6 @@ ifneq ($(shell echo),) endif PROGS = ar65 \ - c1p65 \ ca65 \ cc65 \ cl65 \ diff --git a/src/c1p65/main.c b/src/c1p65/main.c deleted file mode 100644 index bf74f73c1..000000000 --- a/src/c1p65/main.c +++ /dev/null @@ -1,232 +0,0 @@ -/* Object file conversion utility for Challenger 1P - - by Stephan Muehlstrasser -*/ - - -#include -#include -#include -#include -#include -#include - -/* common stuff */ -#include "abend.h" -#include "cmdline.h" -#include "fname.h" -#include "chartype.h" -#include "target.h" -#include "version.h" -#include "xmalloc.h" - -static void Usage (void) -{ - printf ( - "Usage: %s [options] file\n" - "Short options:\n" - " -V\t\t\tPrint the version number\n" - " -h\t\t\tHelp (this text)\n" - " -n\t\tNo automatic start after loading program\n" - " -o name\t\tName the C1P output file (default: .c1p)\n" - " -S addr\t\tLoad address (default 0x300)\n" - "\n" - "Long options:\n" - " --help\t\tHelp (this text)\n" - " --version\t\tPrint the version number\n", - ProgName); -} - -static void OptHelp (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print usage information and exit */ -{ - Usage (); - exit (EXIT_SUCCESS); -} - - -static void OptVersion (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print the program version */ -{ - fprintf (stderr, "grc65 V%s\n", GetVersionAsString ()); -} - - -static unsigned long CvtNumber (const char* Arg, const char* Number) -/* Convert a number from a string. Allow '$' and '0x' prefixes for hex - * numbers. Duplicated from ld65's main.c. - */ -{ - unsigned long Val; - int Converted; - - /* Convert */ - if (*Number == '$') { - ++Number; - Converted = sscanf (Number, "%lx", &Val); - } else { - Converted = sscanf (Number, "%li", (long*)&Val); - } - - /* Check if we do really have a number */ - if (Converted != 1) { - AbEnd ("Invalid number given in argument: %s\n", Arg); - } - - /* Return the result */ - return Val; -} - -/* Commands of C1P PROM monitor */ -#define ADDRESS_MODE_CMD '.' -#define DATA_MODE_CMD '/' -#define EXECUTE_CMD 'G' -#define DATA_MODE_ADDRESS 0x00FB - -/* Transform the cc65 executable binary into a series of - commands that make the C1P PROM monitor load the bytes - into memory. -*/ -static void Transform (unsigned long StartAddress, FILE *In, FILE *Out, - unsigned AutoStart) -{ - int c; - - /* Position to the start address */ - fprintf(Out, "%c%04.4X%c", ADDRESS_MODE_CMD, - StartAddress & 0xFFFF, DATA_MODE_CMD); - - /* Loop over all input bytes and enter them one by one */ - for (c = getc(In); c != EOF; c = getc(In)) { - fprintf(Out, "%02.2X\r", (unsigned int) c & 0xFF); - } - - if (AutoStart) { - /* Execute */ - fprintf (Out, "%c%04.4x%c", - ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, - EXECUTE_CMD); - } - else { - /* Store 00 to 0x00FB to enable keyboard input at the end */ - fprintf(Out, "%c%04.4X%c%02.2X", ADDRESS_MODE_CMD, - 0x00FB, DATA_MODE_CMD, 0x00); - } -} - -/* Default suffix for C1P object file */ -#define C1P_SUFFIX ".c1p" - -int main (int argc, char *argv[]) -{ - /* Program long options */ - static const LongOpt OptTab[] = { - { "--help", 0, OptHelp}, - { "--version", 0, OptVersion}, - }; - - /* Initialize input and output file name */ - const char* InputFile = 0; - const char* OutputFile = 0; - char *GeneratedOutputFile = 0; - - /* Initialize file pointers */ - FILE *InputFileFp = 0; - FILE *OutputFileFp = 0; - - /* Initialize with default start address defined in c1p.cfg */ - unsigned long StartAddr = 0x200; - - /* Start program automatically after loading */ - unsigned AutoStart = 1; - - unsigned int I; - - /* Initialize the cmdline module */ - InitCmdLine (&argc, &argv, "c1p65"); - - /* Check the parameters */ - I = 1; - while (I < ArgCount) { - - /* Get the argument */ - const char* Arg = ArgVec [I]; - - /* Check for an option */ - if (Arg[0] == '-') { - switch (Arg[1]) { - - case '-': - LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); - break; - - case 'n': - AutoStart = 0; - break; - - case 'o': - OutputFile = GetArg(&I, 2); - break; - - case 'S': - StartAddr = CvtNumber (Arg, GetArg (&I, 2)); - break; - - case 'h': - case '?': - OptHelp (Arg, 0); - break; - - case 'V': - OptVersion (Arg, 0); - break; - - default: - UnknownOption (Arg); - } - - } else { - if (InputFile) { - fprintf (stderr, "additional file specs ignored\n"); - } else { - InputFile = Arg; - } - } - - /* Next argument */ - ++I; - } - - if (!InputFile) AbEnd ("No input file"); - - if (!OutputFile) { - const size_t len = strlen(InputFile) + sizeof(C1P_SUFFIX); - - GeneratedOutputFile = (char *) xmalloc(len); - sprintf(GeneratedOutputFile, "%s%s", InputFile, C1P_SUFFIX); - OutputFile = GeneratedOutputFile; - } - - /* Open input and output files */ - InputFileFp = fopen(InputFile, "rb"); - if (!InputFileFp) AbEnd ("Unable to open input file"); - - OutputFileFp = fopen(OutputFile, "wb"); - if (!OutputFileFp) AbEnd ("Unable to open output file"); - - /* Generate object file */ - Transform (StartAddr, InputFileFp, OutputFileFp, AutoStart); - - /* Cleanup */ - if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file"); - - if (fclose(OutputFileFp) == EOF) AbEnd ("Error closing output file"); - - if (GeneratedOutputFile) { - xfree(GeneratedOutputFile); - } - - return EXIT_SUCCESS; -} diff --git a/src/cc65.sln b/src/cc65.sln index 543038755..9d0f2cc2e 100644 --- a/src/cc65.sln +++ b/src/cc65.sln @@ -1,130 +1,119 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{71DC1F68-BFC4-478C-8655-C8E9C9654D2B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cc65", "cc65.vcxproj", "{B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ca65", "ca65.vcxproj", "{D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ar65", "ar65.vcxproj", "{5E8C19C6-B167-440C-8BEF-3CBF109CDB49}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ld65", "ld65.vcxproj", "{26C749A0-814C-47A2-9D36-AE92AE932FE4}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cl65", "cl65.vcxproj", "{F657912F-050A-488B-B203-50ED5715CDD7}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "da65", "da65.vcxproj", "{0BCFB793-2B25-40E2-B265-75848824AC4C}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "co65", "co65.vcxproj", "{F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grc65", "grc65.vcxproj", "{E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "od65", "od65.vcxproj", "{FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sp65", "sp65.vcxproj", "{4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{002A366E-2863-46A8-BDDE-DDF534AAEC73}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c1p65", "c1p65.vcxproj", "{4E031DE0-82B4-4204-8529-536626F7E0DF}" - ProjectSection(ProjectDependencies) = postProject - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.ActiveCfg = Debug|Win32 - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.Build.0 = Debug|Win32 - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.ActiveCfg = Release|Win32 - {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.Build.0 = Release|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.ActiveCfg = Debug|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.Build.0 = Debug|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.ActiveCfg = Release|Win32 - {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.Build.0 = Release|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.ActiveCfg = Debug|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.Build.0 = Debug|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.ActiveCfg = Release|Win32 - {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.Build.0 = Release|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.ActiveCfg = Debug|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.Build.0 = Debug|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.ActiveCfg = Release|Win32 - {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.Build.0 = Release|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.ActiveCfg = Debug|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.Build.0 = Debug|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.ActiveCfg = Release|Win32 - {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.Build.0 = Release|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.ActiveCfg = Debug|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.Build.0 = Debug|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.ActiveCfg = Release|Win32 - {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.Build.0 = Release|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.ActiveCfg = Debug|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.Build.0 = Debug|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.ActiveCfg = Release|Win32 - {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.Build.0 = Release|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.ActiveCfg = Debug|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.Build.0 = Debug|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.ActiveCfg = Release|Win32 - {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.Build.0 = Release|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.ActiveCfg = Debug|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.Build.0 = Debug|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.ActiveCfg = Release|Win32 - {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.Build.0 = Release|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.ActiveCfg = Debug|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.Build.0 = Debug|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.ActiveCfg = Release|Win32 - {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.Build.0 = Release|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.ActiveCfg = Debug|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.Build.0 = Debug|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.ActiveCfg = Release|Win32 - {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.Build.0 = Release|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.ActiveCfg = Debug|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.Build.0 = Debug|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.ActiveCfg = Release|Win32 - {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.Build.0 = Release|Win32 - {4E031DE0-82B4-4204-8529-536626F7E0DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E031DE0-82B4-4204-8529-536626F7E0DF}.Debug|Win32.Build.0 = Debug|Win32 - {4E031DE0-82B4-4204-8529-536626F7E0DF}.Release|Win32.ActiveCfg = Release|Win32 - {4E031DE0-82B4-4204-8529-536626F7E0DF}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{71DC1F68-BFC4-478C-8655-C8E9C9654D2B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cc65", "cc65.vcxproj", "{B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ca65", "ca65.vcxproj", "{D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ar65", "ar65.vcxproj", "{5E8C19C6-B167-440C-8BEF-3CBF109CDB49}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ld65", "ld65.vcxproj", "{26C749A0-814C-47A2-9D36-AE92AE932FE4}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cl65", "cl65.vcxproj", "{F657912F-050A-488B-B203-50ED5715CDD7}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "da65", "da65.vcxproj", "{0BCFB793-2B25-40E2-B265-75848824AC4C}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "co65", "co65.vcxproj", "{F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grc65", "grc65.vcxproj", "{E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "od65", "od65.vcxproj", "{FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sp65", "sp65.vcxproj", "{4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sim65", "sim65.vcxproj", "{002A366E-2863-46A8-BDDE-DDF534AAEC73}" + ProjectSection(ProjectDependencies) = postProject + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} = {71DC1F68-BFC4-478C-8655-C8E9C9654D2B} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.ActiveCfg = Debug|Win32 + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Debug|Win32.Build.0 = Debug|Win32 + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.ActiveCfg = Release|Win32 + {71DC1F68-BFC4-478C-8655-C8E9C9654D2B}.Release|Win32.Build.0 = Release|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.ActiveCfg = Debug|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Debug|Win32.Build.0 = Debug|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.ActiveCfg = Release|Win32 + {B17EDBD5-DC04-4970-9CBD-56A98B6A3FCA}.Release|Win32.Build.0 = Release|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.ActiveCfg = Debug|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Debug|Win32.Build.0 = Debug|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.ActiveCfg = Release|Win32 + {D28CB737-E6CA-49C4-8CE9-FF05F86DD4EC}.Release|Win32.Build.0 = Release|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.ActiveCfg = Debug|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Debug|Win32.Build.0 = Debug|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.ActiveCfg = Release|Win32 + {5E8C19C6-B167-440C-8BEF-3CBF109CDB49}.Release|Win32.Build.0 = Release|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.ActiveCfg = Debug|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Debug|Win32.Build.0 = Debug|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.ActiveCfg = Release|Win32 + {26C749A0-814C-47A2-9D36-AE92AE932FE4}.Release|Win32.Build.0 = Release|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.ActiveCfg = Debug|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Debug|Win32.Build.0 = Debug|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.ActiveCfg = Release|Win32 + {F657912F-050A-488B-B203-50ED5715CDD7}.Release|Win32.Build.0 = Release|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.ActiveCfg = Debug|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Debug|Win32.Build.0 = Debug|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.ActiveCfg = Release|Win32 + {0BCFB793-2B25-40E2-B265-75848824AC4C}.Release|Win32.Build.0 = Release|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.ActiveCfg = Debug|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Debug|Win32.Build.0 = Debug|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.ActiveCfg = Release|Win32 + {F5DB5D1A-05BC-48FE-B346-4E96DD522AA2}.Release|Win32.Build.0 = Release|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.ActiveCfg = Debug|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Debug|Win32.Build.0 = Debug|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.ActiveCfg = Release|Win32 + {E0FD0AB3-3BEE-496F-8108-A8E0F8933F39}.Release|Win32.Build.0 = Release|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.ActiveCfg = Debug|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Debug|Win32.Build.0 = Debug|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.ActiveCfg = Release|Win32 + {FF8576C2-1253-44FE-A51B-D9AE35F3CEAD}.Release|Win32.Build.0 = Release|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.ActiveCfg = Debug|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Debug|Win32.Build.0 = Debug|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.ActiveCfg = Release|Win32 + {4388D1AF-C7EA-4AD4-8E80-CA1FB7BF76BF}.Release|Win32.Build.0 = Release|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.ActiveCfg = Debug|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Debug|Win32.Build.0 = Debug|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.ActiveCfg = Release|Win32 + {002A366E-2863-46A8-BDDE-DDF534AAEC73}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From aedefb81ec7b10d3d77522bb45e2145a79078cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Mon, 5 Jan 2015 21:28:39 +0100 Subject: [PATCH 39/63] Adapted to cc65 assembler coding conventions Assembler statements are written in lowercase. --- libsrc/c1p/crt0.s | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libsrc/c1p/crt0.s b/libsrc/c1p/crt0.s index 8f25c2a8d..dde348ee8 100644 --- a/libsrc/c1p/crt0.s +++ b/libsrc/c1p/crt0.s @@ -23,41 +23,41 @@ ; --------------------------------------------------------------------------- ; A little light 6502 housekeeping -_init: LDX #$FF ; Initialize stack pointer to $01FF - TXS - CLD ; Clear decimal mode +_init: ldx #$FF ; Initialize stack pointer to $01FF + txs + cld ; Clear decimal mode ; --------------------------------------------------------------------------- ; Initialize screen width ; TODO: Can initialization be done in a more idiomatic way? ; TODO: Create function for changing screen width - LDA #$18 - STA SCR_LINELEN + lda #$18 + sta SCR_LINELEN ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer - LDA #<(__RAM_START__ + __RAM_SIZE__) - STA sp - LDA #>(__RAM_START__ + __RAM_SIZE__) - STA sp+1 + lda #<(__RAM_START__ + __RAM_SIZE__) + sta sp + lda #>(__RAM_START__ + __RAM_SIZE__) + sta sp+1 ; --------------------------------------------------------------------------- ; Initialize memory storage ; copydata seems to be only necessary for special systems - JSR zerobss ; Clear BSS segment - ; JSR copydata ; Initialize DATA segment - JSR initlib ; Run constructors + jsr zerobss ; Clear BSS segment + ; jsr copydata ; Initialize DATA segment + jsr initlib ; Run constructors ; --------------------------------------------------------------------------- ; Call main() - JSR _main + jsr _main ; --------------------------------------------------------------------------- ; Back from main (this is also the _exit entry): force a software break -_exit: JSR donelib ; Run destructors - BRK +_exit: jsr donelib ; Run destructors + brk From b1f764bdc90d7be9a0e2f74c6aab4b0e8fdb8181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sun, 11 Jan 2015 18:22:36 +0100 Subject: [PATCH 40/63] Minor cleanup of unnecessary newlines. --- cfg/c1p.cfg | 1 - libsrc/c1p/_scrsize.s | 1 - libsrc/c1p/cclear.s | 4 ---- libsrc/c1p/crt0.s | 1 - libsrc/c1p/ctype.s | 1 - libsrc/c1p/cvline.s | 3 --- libsrc/c1p/gotox.s | 4 ---- libsrc/c1p/gotoxy.s | 6 +++--- libsrc/c1p/gotoy.s | 2 -- 9 files changed, 3 insertions(+), 20 deletions(-) diff --git a/cfg/c1p.cfg b/cfg/c1p.cfg index 633298270..59fdd34d8 100644 --- a/cfg/c1p.cfg +++ b/cfg/c1p.cfg @@ -1,7 +1,6 @@ FEATURES { STARTADDRESS: default = $0200; } - SYMBOLS { __STACKSIZE__: type = weak, value = $0400; # 1 kB stack __HIMEM__: type = weak, value = $8000; # 32 kB RAM diff --git a/libsrc/c1p/_scrsize.s b/libsrc/c1p/_scrsize.s index 75de2b349..3b0d71c2f 100644 --- a/libsrc/c1p/_scrsize.s +++ b/libsrc/c1p/_scrsize.s @@ -19,4 +19,3 @@ rts .endproc - diff --git a/libsrc/c1p/cclear.s b/libsrc/c1p/cclear.s index 4412f0bba..4e18c70a3 100644 --- a/libsrc/c1p/cclear.s +++ b/libsrc/c1p/cclear.s @@ -27,7 +27,3 @@ L1: lda #$20 ; Blank - screen code dec tmp1 bne L1 L9: rts - - - - diff --git a/libsrc/c1p/crt0.s b/libsrc/c1p/crt0.s index dde348ee8..908943e91 100644 --- a/libsrc/c1p/crt0.s +++ b/libsrc/c1p/crt0.s @@ -60,4 +60,3 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF _exit: jsr donelib ; Run destructors brk - diff --git a/libsrc/c1p/ctype.s b/libsrc/c1p/ctype.s index dd7ac62c3..fa901c189 100644 --- a/libsrc/c1p/ctype.s +++ b/libsrc/c1p/ctype.s @@ -287,4 +287,3 @@ __ctype: .byte $00 ; 253/fd _y'_acute__ .byte $00 ; 254/fe _sm_thorn__ .byte $00 ; 255/ff _y"_dieres_ - diff --git a/libsrc/c1p/cvline.s b/libsrc/c1p/cvline.s index 607a4c691..c485918ee 100644 --- a/libsrc/c1p/cvline.s +++ b/libsrc/c1p/cvline.s @@ -27,6 +27,3 @@ L1: lda #$95 ; Vertical bar dec tmp1 bne L1 L9: rts - - - diff --git a/libsrc/c1p/gotox.s b/libsrc/c1p/gotox.s index 315e1b5ee..fb84975d1 100644 --- a/libsrc/c1p/gotox.s +++ b/libsrc/c1p/gotox.s @@ -5,13 +5,9 @@ ; ; void gotox (unsigned char x); ; - .export _gotox .import plot .importzp CURS_X _gotox: sta CURS_X ; Set new position jmp plot ; And activate it - - - diff --git a/libsrc/c1p/gotoxy.s b/libsrc/c1p/gotoxy.s index 64c6bd21d..32d1f1df2 100644 --- a/libsrc/c1p/gotoxy.s +++ b/libsrc/c1p/gotoxy.s @@ -1,9 +1,11 @@ ; +; copied from CBM implementation +; +; originally by: ; Ullrich von Bassewitz, 06.08.1998 ; ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy .import popa, plot .importzp CURS_X, CURS_Y @@ -13,5 +15,3 @@ _gotoxy: jsr popa ; Get X sta CURS_X ; Set X jmp plot ; Set the cursor position - - diff --git a/libsrc/c1p/gotoy.s b/libsrc/c1p/gotoy.s index e9e81451a..fcd60dd31 100644 --- a/libsrc/c1p/gotoy.s +++ b/libsrc/c1p/gotoy.s @@ -5,11 +5,9 @@ ; ; void gotoy (unsigned char y); ; - .export _gotoy .import plot .importzp CURS_Y _gotoy: sta CURS_Y ; Set the new position jmp plot ; And activate it - From 19b3c1b32bc8a3f5a17d8b389192afbc73e35143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Sat, 31 Jan 2015 22:45:18 +0100 Subject: [PATCH 41/63] Configuration file for assembler-only build. --- cfg/c1p-asm.cfg | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cfg/c1p-asm.cfg diff --git a/cfg/c1p-asm.cfg b/cfg/c1p-asm.cfg new file mode 100644 index 000000000..57689b96d --- /dev/null +++ b/cfg/c1p-asm.cfg @@ -0,0 +1,20 @@ +FEATURES { + STARTADDRESS: default = $0200; +} +SYMBOLS { + __STACKSIZE__: type = weak, value = $0400; # 1 kB stack + __HIMEM__: type = weak, value = $8000; # 32 kB RAM +} +MEMORY { + # for size of ZP see runtime/zeropage.s and c1p/extzp.s + ZP: file = "", define = yes, start = $0002, size = $001A + $0006; + RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; +} +SEGMENTS { + INIT: load = RAM, type = ro, define = yes, optional = yes; + CODE: load = RAM, type = rw; + RODATA: load = RAM, type = rw; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} \ No newline at end of file From 14c7e9fd1646ca07ee9c5abe1c23a85abba1df4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 3 Feb 2015 22:42:35 +0100 Subject: [PATCH 42/63] Rename c1p target to osic1p --- cfg/{c1p-asm.cfg => osic1p-asm.cfg} | 0 cfg/{c1p.cfg => osic1p.cfg} | 0 include/conio.h | 2 +- include/{c1p.h => osic1p.h} | 8 +- libsrc/Makefile | 2 +- libsrc/{c1p => osic1p}/_scrsize.s | 0 libsrc/{c1p => osic1p}/cclear.s | 0 libsrc/{c1p => osic1p}/cgetc.s | 2 +- libsrc/{c1p => osic1p}/chline.s | 0 libsrc/{c1p => osic1p}/clrscr.s | 2 +- libsrc/{c1p => osic1p}/cputc.s | 2 +- libsrc/{c1p => osic1p}/crt0.s | 0 libsrc/{c1p => osic1p}/ctype.s | 0 libsrc/{c1p => osic1p}/cvline.s | 0 libsrc/{c1p => osic1p}/extzp.inc | 0 libsrc/{c1p => osic1p}/extzp.s | 2 +- libsrc/{c1p => osic1p}/gotox.s | 0 libsrc/{c1p => osic1p}/gotoxy.s | 0 libsrc/{c1p => osic1p}/gotoy.s | 0 libsrc/{c1p => osic1p}/oserror.s | 0 libsrc/{c1p/c1p.inc => osic1p/osic1p.inc} | 0 libsrc/{c1p => osic1p}/wherex.s | 0 libsrc/{c1p => osic1p}/wherey.s | 0 src/c1p65.vcxproj | 94 ----------------------- src/ca65/main.c | 2 +- src/cc65/main.c | 2 +- src/common/target.c | 6 +- src/common/target.h | 6 +- 28 files changed, 18 insertions(+), 112 deletions(-) rename cfg/{c1p-asm.cfg => osic1p-asm.cfg} (100%) rename cfg/{c1p.cfg => osic1p.cfg} (100%) rename include/{c1p.h => osic1p.h} (92%) rename libsrc/{c1p => osic1p}/_scrsize.s (100%) rename libsrc/{c1p => osic1p}/cclear.s (100%) rename libsrc/{c1p => osic1p}/cgetc.s (93%) rename libsrc/{c1p => osic1p}/chline.s (100%) rename libsrc/{c1p => osic1p}/clrscr.s (91%) rename libsrc/{c1p => osic1p}/cputc.s (98%) rename libsrc/{c1p => osic1p}/crt0.s (100%) rename libsrc/{c1p => osic1p}/ctype.s (100%) rename libsrc/{c1p => osic1p}/cvline.s (100%) rename libsrc/{c1p => osic1p}/extzp.inc (100%) rename libsrc/{c1p => osic1p}/extzp.s (89%) rename libsrc/{c1p => osic1p}/gotox.s (100%) rename libsrc/{c1p => osic1p}/gotoxy.s (100%) rename libsrc/{c1p => osic1p}/gotoy.s (100%) rename libsrc/{c1p => osic1p}/oserror.s (100%) rename libsrc/{c1p/c1p.inc => osic1p/osic1p.inc} (100%) rename libsrc/{c1p => osic1p}/wherex.s (100%) rename libsrc/{c1p => osic1p}/wherey.s (100%) delete mode 100644 src/c1p65.vcxproj diff --git a/cfg/c1p-asm.cfg b/cfg/osic1p-asm.cfg similarity index 100% rename from cfg/c1p-asm.cfg rename to cfg/osic1p-asm.cfg diff --git a/cfg/c1p.cfg b/cfg/osic1p.cfg similarity index 100% rename from cfg/c1p.cfg rename to cfg/osic1p.cfg diff --git a/include/conio.h b/include/conio.h index f59375a63..10806785c 100644 --- a/include/conio.h +++ b/include/conio.h @@ -78,7 +78,7 @@ #elif defined(__NES__) # include #elif defined(__OSIC1P__) -# include +# include #endif diff --git a/include/c1p.h b/include/osic1p.h similarity index 92% rename from include/c1p.h rename to include/osic1p.h index 5789d7156..57fe0cd24 100644 --- a/include/c1p.h +++ b/include/osic1p.h @@ -1,12 +1,12 @@ /*****************************************************************************/ /* */ -/* c1p.h */ +/* osic1p.h */ /* */ /* Challenger 1P system specific definitions */ /* */ /* */ /* */ -/* (C) 2014 Stephan Muehlstrasser */ +/* (C) 2015 Stephan Muehlstrasser */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -28,8 +28,8 @@ /* */ /*****************************************************************************/ -#ifndef _C1P_H -#define _C1P_H +#ifndef _OSIC1P_H +#define _OSIC1P_H /* Check for errors */ #if !defined(__OSIC1P__) diff --git a/libsrc/Makefile b/libsrc/Makefile index b35ae1e38..42aaf078b 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -20,11 +20,11 @@ TARGETS = apple2 \ atarixl \ atari5200 \ atmos \ - c1p \ $(CBMS) \ $(GEOS) \ lynx \ nes \ + osic1p \ sim6502 \ sim65c02 \ supervision diff --git a/libsrc/c1p/_scrsize.s b/libsrc/osic1p/_scrsize.s similarity index 100% rename from libsrc/c1p/_scrsize.s rename to libsrc/osic1p/_scrsize.s diff --git a/libsrc/c1p/cclear.s b/libsrc/osic1p/cclear.s similarity index 100% rename from libsrc/c1p/cclear.s rename to libsrc/osic1p/cclear.s diff --git a/libsrc/c1p/cgetc.s b/libsrc/osic1p/cgetc.s similarity index 93% rename from libsrc/c1p/cgetc.s rename to libsrc/osic1p/cgetc.s index b17e76572..b5a519667 100644 --- a/libsrc/c1p/cgetc.s +++ b/libsrc/osic1p/cgetc.s @@ -4,7 +4,7 @@ .export _cgetc .import cursor - .include "c1p.inc" + .include "osic1p.inc" .include "extzp.inc" ; Input routine from 65V PROM MONITOR, show cursor if enabled diff --git a/libsrc/c1p/chline.s b/libsrc/osic1p/chline.s similarity index 100% rename from libsrc/c1p/chline.s rename to libsrc/osic1p/chline.s diff --git a/libsrc/c1p/clrscr.s b/libsrc/osic1p/clrscr.s similarity index 91% rename from libsrc/c1p/clrscr.s rename to libsrc/osic1p/clrscr.s index ce221f31e..32975526f 100644 --- a/libsrc/c1p/clrscr.s +++ b/libsrc/osic1p/clrscr.s @@ -4,7 +4,7 @@ .export _clrscr .import plot .importzp CURS_X, CURS_Y - .include "c1p.inc" + .include "osic1p.inc" ; Adapted from the Challenger Character Graphics ; Reference Manual, "2.3.3 MACHINE LANGUAGE SCREEN CLEAR" diff --git a/libsrc/c1p/cputc.s b/libsrc/osic1p/cputc.s similarity index 98% rename from libsrc/c1p/cputc.s rename to libsrc/osic1p/cputc.s index ca9152aa7..d343da951 100644 --- a/libsrc/c1p/cputc.s +++ b/libsrc/osic1p/cputc.s @@ -9,7 +9,7 @@ .export newline, plot .import popa, _gotoxy - .include "c1p.inc" + .include "osic1p.inc" .include "extzp.inc" _cputcxy: diff --git a/libsrc/c1p/crt0.s b/libsrc/osic1p/crt0.s similarity index 100% rename from libsrc/c1p/crt0.s rename to libsrc/osic1p/crt0.s diff --git a/libsrc/c1p/ctype.s b/libsrc/osic1p/ctype.s similarity index 100% rename from libsrc/c1p/ctype.s rename to libsrc/osic1p/ctype.s diff --git a/libsrc/c1p/cvline.s b/libsrc/osic1p/cvline.s similarity index 100% rename from libsrc/c1p/cvline.s rename to libsrc/osic1p/cvline.s diff --git a/libsrc/c1p/extzp.inc b/libsrc/osic1p/extzp.inc similarity index 100% rename from libsrc/c1p/extzp.inc rename to libsrc/osic1p/extzp.inc diff --git a/libsrc/c1p/extzp.s b/libsrc/osic1p/extzp.s similarity index 89% rename from libsrc/c1p/extzp.s rename to libsrc/osic1p/extzp.s index c55156f82..dfa84a61c 100644 --- a/libsrc/c1p/extzp.s +++ b/libsrc/osic1p/extzp.s @@ -18,4 +18,4 @@ SCR_LINELEN: .byte 24 SCREEN_PTR: .res 2 ; size 6 -; Adjust size of this segment in c1p.cfg if the size changes +; Adjust size of this segment in osic1p.cfg if the size changes diff --git a/libsrc/c1p/gotox.s b/libsrc/osic1p/gotox.s similarity index 100% rename from libsrc/c1p/gotox.s rename to libsrc/osic1p/gotox.s diff --git a/libsrc/c1p/gotoxy.s b/libsrc/osic1p/gotoxy.s similarity index 100% rename from libsrc/c1p/gotoxy.s rename to libsrc/osic1p/gotoxy.s diff --git a/libsrc/c1p/gotoy.s b/libsrc/osic1p/gotoy.s similarity index 100% rename from libsrc/c1p/gotoy.s rename to libsrc/osic1p/gotoy.s diff --git a/libsrc/c1p/oserror.s b/libsrc/osic1p/oserror.s similarity index 100% rename from libsrc/c1p/oserror.s rename to libsrc/osic1p/oserror.s diff --git a/libsrc/c1p/c1p.inc b/libsrc/osic1p/osic1p.inc similarity index 100% rename from libsrc/c1p/c1p.inc rename to libsrc/osic1p/osic1p.inc diff --git a/libsrc/c1p/wherex.s b/libsrc/osic1p/wherex.s similarity index 100% rename from libsrc/c1p/wherex.s rename to libsrc/osic1p/wherex.s diff --git a/libsrc/c1p/wherey.s b/libsrc/osic1p/wherey.s similarity index 100% rename from libsrc/c1p/wherey.s rename to libsrc/osic1p/wherey.s diff --git a/src/c1p65.vcxproj b/src/c1p65.vcxproj deleted file mode 100644 index dcc8f9926..000000000 --- a/src/c1p65.vcxproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - {4E031DE0-82B4-4204-8529-536626F7E0DF} - Win32Proj - c1p65 - - - - Application - true - v120 - - - - - Application - false - v120 - true - - - - - - - - - - - - - - - true - $(SolutionDir)..\bin\ - $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ - - - false - $(SolutionDir)..\bin\ - $(SolutionDir)..\wrk\$(ProjectName)\$(Configuration)\ - - - - - - Level3 - Disabled - _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - common - - - Console - true - $(IntDir)..\..\common\$(Configuration)\common.lib - - - - - Level3 - - - MaxSpeed - true - true - _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - common - - - Console - true - true - true - $(IntDir)..\..\common\$(Configuration)\common.lib - - - - - - \ No newline at end of file diff --git a/src/ca65/main.c b/src/ca65/main.c index 50878f47a..508f49603 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -303,7 +303,7 @@ static void SetSys (const char* Sys) NewSymbol ("__SIM65C02__", 1); break; - case TGT_C1P: + case TGT_OSIC1P: NewSymbol ("__OSIC1P__", 1); break; diff --git a/src/cc65/main.c b/src/cc65/main.c index b8963258d..ece22041a 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -258,7 +258,7 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__SIM65C02__", 1); break; - case TGT_C1P: + case TGT_OSIC1P: DefineNumericMacro ("__OSIC1P__", 1); break; diff --git a/src/common/target.c b/src/common/target.c index b909e4d70..0b44ffa30 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -131,7 +131,6 @@ static const TargetEntry TargetMap[] = { { "bbc", TGT_BBC }, { "c128", TGT_C128 }, { "c16", TGT_C16 }, - { "c1p", TGT_C1P }, { "c64", TGT_C64 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, @@ -143,6 +142,7 @@ static const TargetEntry TargetMap[] = { { "module", TGT_MODULE }, { "nes", TGT_NES }, { "none", TGT_NONE }, + { "osic1p", TGT_OSIC1P }, { "pet", TGT_PET }, { "plus4", TGT_PLUS4 }, { "sim6502", TGT_SIM6502 }, @@ -163,12 +163,12 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "atarixl", CPU_6502, BINFMT_BINARY, CTAtari }, { "vic20", CPU_6502, BINFMT_BINARY, CTPET }, { "c16", CPU_6502, BINFMT_BINARY, CTPET }, - { "c1p", CPU_6502, BINFMT_BINARY, CTNone }, { "c64", CPU_6502, BINFMT_BINARY, CTPET }, { "c128", CPU_6502, BINFMT_BINARY, CTPET }, { "plus4", CPU_6502, BINFMT_BINARY, CTPET }, { "cbm510", CPU_6502, BINFMT_BINARY, CTPET }, { "cbm610", CPU_6502, BINFMT_BINARY, CTPET }, + { "osic1p", CPU_6502, BINFMT_BINARY, CTNone }, { "pet", CPU_6502, BINFMT_BINARY, CTPET }, { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2", CPU_6502, BINFMT_BINARY, CTNone }, @@ -201,7 +201,7 @@ static int Compare (const void* Key, const void* Entry) return strcmp ((const char*) Key, ((const TargetEntry*)Entry)->Name); } - +#include target_t FindTarget (const char* Name) /* Find a target by name and return the target id. TGT_UNKNOWN is returned if diff --git a/src/common/target.h b/src/common/target.h index 067352deb..edce36fa5 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -59,13 +59,13 @@ typedef enum { TGT_ATARIXL, TGT_VIC20, TGT_C16, - TGT_C1P, TGT_C64, TGT_C128, TGT_PLUS4, TGT_CBM510, TGT_CBM610, - TGT_PET, + TGT_OSIC1P, + TGT_PET, TGT_BBC, TGT_APPLE2, TGT_APPLE2ENH, @@ -76,7 +76,7 @@ typedef enum { TGT_NES, TGT_SUPERVISION, TGT_LYNX, - TGT_SIM6502, + TGT_SIM6502, TGT_SIM65C02, TGT_COUNT /* Number of target systems */ } target_t; From 01b0e10fc35e66e170791c2525f93c7b20dd8cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 3 Feb 2015 22:56:04 +0100 Subject: [PATCH 43/63] Remove tab character. --- src/common/target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/target.c b/src/common/target.c index 0b44ffa30..24734f196 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -168,7 +168,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "plus4", CPU_6502, BINFMT_BINARY, CTPET }, { "cbm510", CPU_6502, BINFMT_BINARY, CTPET }, { "cbm610", CPU_6502, BINFMT_BINARY, CTPET }, - { "osic1p", CPU_6502, BINFMT_BINARY, CTNone }, + { "osic1p", CPU_6502, BINFMT_BINARY, CTNone }, { "pet", CPU_6502, BINFMT_BINARY, CTPET }, { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2", CPU_6502, BINFMT_BINARY, CTNone }, From 072e5e71c2ce377ef448f138b1a03737dfe83f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Thu, 5 Feb 2015 23:01:19 +0100 Subject: [PATCH 44/63] Video RAM mapping table was off by two bytes. Fix contributed by Jeff Tranter. --- libsrc/osic1p/cputc.s | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsrc/osic1p/cputc.s b/libsrc/osic1p/cputc.s index d343da951..9cea78789 100644 --- a/libsrc/osic1p/cputc.s +++ b/libsrc/osic1p/cputc.s @@ -70,10 +70,10 @@ putchar: .rodata -ScrLo: .byte $83, $A3, $C3, $E3, $03, $23, $43, $63 - .byte $83, $A3, $C3, $E3, $03, $23, $43, $63 - .byte $83, $A3, $C3, $E3, $03, $23, $43, $63 - .byte $83 +ScrLo: .byte $85, $A5, $C5, $E5, $05, $25, $45, $65 + .byte $85, $A5, $C5, $E5, $05, $25, $45, $65 + .byte $85, $A5, $C5, $E5, $05, $25, $45, $65 + .byte $85 ScrHi: .byte $D0, $D0, $D0, $D0, $D1, $D1, $D1, $D1 .byte $D1, $D1, $D1, $D1, $D2, $D2, $D2, $D2 From 7754c573d8b901f5b904a50dc848edd58e4ff4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Thu, 5 Feb 2015 23:21:59 +0100 Subject: [PATCH 45/63] Jump to boot prompt after main program exits. --- libsrc/osic1p/crt0.s | 3 ++- libsrc/osic1p/osic1p.inc | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 908943e91..447b65c56 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -14,6 +14,7 @@ .include "zeropage.inc" .include "extzp.inc" +.include "osic1p.inc" ; --------------------------------------------------------------------------- ; Place the startup code in a special segment @@ -59,4 +60,4 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF ; Back from main (this is also the _exit entry): force a software break _exit: jsr donelib ; Run destructors - brk + jmp RESET ; Display boot menu after program exit diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index ad058373a..4ad0e038b 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -2,3 +2,4 @@ SCRNBASE := $D000 ; Base of video RAM VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) INPUTC := $FD00 ; Input character from keyboard +RESET := $FF00 ; Reset address, show boot prompt \ No newline at end of file From 680c62d589932bb342cd5fe9d0969501133d2efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Fri, 6 Feb 2015 22:53:36 +0100 Subject: [PATCH 46/63] Start documentation for Ohio Scientific targets. --- doc/index.sgml | 3 + doc/osi.sgml | 154 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 doc/osi.sgml diff --git a/doc/index.sgml b/doc/index.sgml index 7de8b26ce..921b8c03d 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -134,6 +134,9 @@ Topics specific to the Nintendo Entertainment System. + + Topics specific to the Ohio Scientific machines. + Topics specific to the Commodore PET machines. diff --git a/doc/osi.sgml b/doc/osi.sgml new file mode 100644 index 000000000..c46a2a742 --- /dev/null +++ b/doc/osi.sgml @@ -0,0 +1,154 @@ + + +
+ +Ohio Scientific-specific information for cc65 +<author> +<url url="mailto:stephan.muehlstrasser@web.de" name="Stephan Mühlstrasser"><newline> +<date>2015-02-04 + +<abstract> +An overview over the Ohio Scientific runtime system as it is implemented for the cc65 C +compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Ohio Scientific runtime system as it comes with the +cc65 C compiler. It describes the memory layout, Ohio Scientific-specific header files, +and any pitfalls specific to that platform. + +Please note that Ohio Scientific-specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more +information. + +<sect>Targets<p> + +Currently the target "osic1p" is implemented. This works for the Ohio Scientific +Challenger 1P machine. + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the osic1p target +is a machine language program.<p> + +For uploading into a real machine over the serial port or into an emulator a +program must be converted to a text file that is understood by the 65V PROM +monitor. For this purpose the srec_cat program from the +<url url="http://srecord.sourceforge.net/" name="SRecord"> tool collection can be used. + +Care must be taken that the -offset and -execution-start-address options for the srec_cat +program correspond to the start address of the executable. + +Example for converting an executable "hello" that was built for the default +start address $0200 to an uploadable file "hello.c1p": + +<tscreen> +srec_cat hello -binary -offset 0x200 -o hello.c1p -Ohio_Scientific -execution-start-address=0x200 +</tscreen> + +<sect>Memory layout<p> + +By default programs compiled for the osic1p target are configured for 32 kB RAM. +The RAM size can be configured via the symbol __HIMEM__. + +Special locations: + +<descrip> + <tag/Program start address/ + The default start address is $0200. The start address is configurable + via the compiler option --start-addr. + + <tag/Stack/ + The C runtime stack is located at the top of RAM and growing downwards. + The size is configurable via the symbol __STACKSIZE__. The default + stack size is $0400. + + <tag/Heap/ + The C heap is located at the end of the program and grows towards the C + runtime stack. + + <tag/Video RAM/ + The 1 kB video RAM is located at $D000. On the monitor only a subset + of the available video RAM is visible. The address of the upper left corner + of the visible area is $dollar;D085 and corresponds to conio cursor + position (0, 0). + +</descrip><p> + +Example for building a program with start address $0300, stack size +$0200 and RAM size $0200: + +<tscreen> +cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0300 -t osic1p hello.c +</tscreen> + +<sect>Platform-specific header files<p> + +Programs containing PET-specific code may use the <tt/pet.h/ or <tt/cbm.h/ +header files. + + +<sect1>PET-specific functions<p> + +There are currently no special Ohio Scientific functions. + +<sect1>Hardware access<p> + +There is no specific support for direct hardware access. + +<sect>Loadable drivers<p> + +There are no loadable drivers available. + +<sect>Limitations<p> + +<sect1>conio implementation<p> + +The conio implementation is complete except for the kbhit() function. A +call to cgetc() always blocks until a character is entered. + +<sect1>stdio implementation<p> + +There is no support for stdio at the moment. + +<sect>Other hints<p> + +<sect1>Passing arguments to the program<p> + +There is currently no support for passing arguments to a program. + +<sect1>Program return code<p> + +The program return code currently has no effect. When the main() function +finishes, the boot prompt is shown again. + +<sect>License<p> + +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: + +<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. +</enum> + +</article> From 04469be331b754f91af7e0d3e46f569a2009b194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sat, 7 Feb 2015 00:20:38 +0100 Subject: [PATCH 47/63] Minor corrections to documentation. --- doc/osi.sgml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/osi.sgml b/doc/osi.sgml index c46a2a742..7f6920489 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -42,7 +42,7 @@ is a machine language program.<p> For uploading into a real machine over the serial port or into an emulator a program must be converted to a text file that is understood by the 65V PROM monitor. For this purpose the srec_cat program from the -<url url="http://srecord.sourceforge.net/" name="SRecord"> tool collection can be used. +SRecord (http://srecord.sourceforge.net/) tool collection can be used. Care must be taken that the -offset and -execution-start-address options for the srec_cat program correspond to the start address of the executable. @@ -92,11 +92,11 @@ cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0300 -t osic1p <sect>Platform-specific header files<p> -Programs containing PET-specific code may use the <tt/pet.h/ or <tt/cbm.h/ -header files. +Programs containing Ohio Scientific-specific code may use the <tt/osic1p.h/ +header file. -<sect1>PET-specific functions<p> +<sect1>Ohio Scientific-specific functions<p> There are currently no special Ohio Scientific functions. From 88249a2125ca07353740337266a4155ca241c39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sat, 7 Feb 2015 01:19:03 +0100 Subject: [PATCH 48/63] Fixed URL for SRecord. --- doc/osi.sgml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/osi.sgml b/doc/osi.sgml index 7f6920489..85d4dca44 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -42,7 +42,8 @@ is a machine language program.<p> For uploading into a real machine over the serial port or into an emulator a program must be converted to a text file that is understood by the 65V PROM monitor. For this purpose the srec_cat program from the -SRecord (http://srecord.sourceforge.net/) tool collection can be used. +<url url="http://srecord.sourceforge.net/" name="SRecord"> +tool collection can be used. Care must be taken that the -offset and -execution-start-address options for the srec_cat program correspond to the start address of the executable. From da8ec4f7b1c295bc112f75b246d4432fff0d1b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sun, 8 Feb 2015 15:06:55 +0100 Subject: [PATCH 49/63] Completing OSI documentation. --- doc/intro.sgml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/osi.sgml | 30 ++++++++++++++++++++-- 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/doc/intro.sgml b/doc/intro.sgml index 02c5c83d5..5ffef7e69 100644 --- a/doc/intro.sgml +++ b/doc/intro.sgml @@ -513,6 +513,75 @@ directory notePad. Look at the eight file-positions on each page until you see The output is shown in a GEOS dialog box; click <bf/OK/ when you have finished reading it. +<sect1>Ohio Scientific Challenger 1P<p> +Available at <url url="http://www.pcjs.org/docs/c1pjs/" name="C1Pjs">: + +Emulates the Ohio Scientific Challenger 1P computer in different configurations. +The 32 kb RAM machine that must be used with the default compiler settings is +<url url="http://www.pcjs.org/devices/c1p/machine/32kb/" name="here">. + +In addition the srec_cat program from the +<url url="http://srecord.sourceforge.net/" name="SRecord"> +tool collection must be installed. Some Linux distributions also provide the +srecord package that can be installed directly from the distribution's +repository. + +The osic1p runtime library directly returns to the boot prompt when the +main() program exits. Therefore the C file in the tutorial must be slightly +modified in order to see the results on the screen. Otherwise the program +would print the text string and then jump to the boot prompt, making it +impossible to see the results of running the tutorial program. + +In addition to that the cc65 target does not yet have support for stdio +functions. Only the functions from the conio library are available. + +Therefore modify the main() function in hello.c as follows: + +<tscreen> +#include <conio.h> +#include <stdlib.h> + +extern const char text[]; /* In text.s */ + +int main (void) +{ + clrscr(); + cprintf ("%s\r\nPress <RETURN>\r\n", text); + cgetc(); + return EXIT_SUCCESS; +} +</tscreen> + +Compile the tutorial with + +<tscreen><verb> +cl65 -O -t osic1p hello.c text.s +</verb></tscreen> + +Convert the executable file into a text file that can be loaded via +the Ohio Scientific 65V PROM monitor at start address 0x200: + +<tscreen><verb> +srec_cat hello -binary -offset 0x200 -o hello.c1p -Ohio_Scientific -execution-start-address=0x200 +</verb></tscreen> + +Open the URL <url url="http://www.pcjs.org/devices/c1p/machine/32kb/" name="http://www.pcjs.org/devices/c1p/machine/32kb/"> +in your browser and wait until the emulator is loaded. Click on the BREAK +button to display the boot prompt, then press the M key to enter the +65V PROM monitor. Press the "Choose File" button and select the hello.c1p +that was created as the output of the above invocation of the srec_cat +command. Press the "Load" button. You should see the following text on the +screen: + +<tscreen><verb> +Hello world! +Press <RETURN> +</verb></tscreen> + +After hitting the RETURN key you should see the boot prompt again. + +The program can also be uploaded over the serial port to a real Challenger 1P +computer. <sect1>Contributions wanted<p> diff --git a/doc/osi.sgml b/doc/osi.sgml index 85d4dca44..7152f2815 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -79,7 +79,7 @@ Special locations: <tag/Video RAM/ The 1 kB video RAM is located at $D000. On the monitor only a subset of the available video RAM is visible. The address of the upper left corner - of the visible area is $dollar;D085 and corresponds to conio cursor + of the visible area is $D085 and corresponds to conio cursor position (0, 0). </descrip><p> @@ -91,12 +91,38 @@ Example for building a program with start address $0300, stack size cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0300 -t osic1p hello.c </tscreen> +<sect>Linker configurations<p> + +The ld65 linker comes with a default config file "osic1p.cfg" for the Ohio Scientific +Challenger 1P, which is implicitly used via <tt/-t osic1p/. The +osic1p package comes with additional secondary linker config files, which are +used via <tt/-t osic1p -C <configfile>/. + +<sect1>default config file (<tt/osic1p.cfg/)<p> + +The default configuration is tailored to C programs. + +<sect1><tt/osic1p-asm.cfg/<p> + +This configuration is made for assembler programmers who don't need a special +setup. + +To use this config file, assemble with <tt/-t osic1p/ and link with +<tt/-C osic1p-asm.cfg/. The former will make sure that correct runtime library +is used, while the latter supplies the actual config. When using <tt/cl65/, +use both command line options. + +Sample command line for <tt/cl65/: + +<tscreen><verb> +cl65 -o program -t osic1p -C osic1p-asm.cfg source.s +</verb></tscreen> + <sect>Platform-specific header files<p> Programs containing Ohio Scientific-specific code may use the <tt/osic1p.h/ header file. - <sect1>Ohio Scientific-specific functions<p> There are currently no special Ohio Scientific functions. From a1cc85768e95cb6d775cb9003e30d5e027277946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sun, 8 Feb 2015 15:46:33 +0100 Subject: [PATCH 50/63] Minor corrections. --- doc/intro.sgml | 30 +++++++++++++++--------------- doc/osi.sgml | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/intro.sgml b/doc/intro.sgml index 5ffef7e69..41f359278 100644 --- a/doc/intro.sgml +++ b/doc/intro.sgml @@ -520,24 +520,23 @@ Emulates the Ohio Scientific Challenger 1P computer in different configurations. The 32 kb RAM machine that must be used with the default compiler settings is <url url="http://www.pcjs.org/devices/c1p/machine/32kb/" name="here">. -In addition the srec_cat program from the +In addition to cc65 the srec_cat program from the <url url="http://srecord.sourceforge.net/" name="SRecord"> tool collection must be installed. Some Linux distributions also provide the -srecord package that can be installed directly from the distribution's -repository. +srecord package directly as an installable package. -The osic1p runtime library directly returns to the boot prompt when the +The osic1p runtime library returns to the boot prompt when the main() program exits. Therefore the C file in the tutorial must be slightly modified in order to see the results on the screen. Otherwise the program would print the text string and then jump to the boot prompt, making it impossible to see the results of running the tutorial program. -In addition to that the cc65 target does not yet have support for stdio +In addition to that the osic1p target does not yet have support for stdio functions. Only the functions from the conio library are available. -Therefore modify the main() function in hello.c as follows: +Therefore modify the hello.c source file as follows: -<tscreen> +<tscreen><code> #include <conio.h> #include <stdlib.h> @@ -545,12 +544,12 @@ extern const char text[]; /* In text.s */ int main (void) { - clrscr(); + clrscr (); cprintf ("%s\r\nPress <RETURN>\r\n", text); - cgetc(); + cgetc (); return EXIT_SUCCESS; } -</tscreen> +</code></tscreen> Compile the tutorial with @@ -566,10 +565,10 @@ srec_cat hello -binary -offset 0x200 -o hello.c1p -Ohio_Scientific -execution-st </verb></tscreen> Open the URL <url url="http://www.pcjs.org/devices/c1p/machine/32kb/" name="http://www.pcjs.org/devices/c1p/machine/32kb/"> -in your browser and wait until the emulator is loaded. Click on the BREAK -button to display the boot prompt, then press the M key to enter the -65V PROM monitor. Press the "Choose File" button and select the hello.c1p -that was created as the output of the above invocation of the srec_cat +and wait until the emulator has been loaded. Click on the "BREAK" +button to display the boot prompt, then press the "M" key to enter the +65V PROM monitor. Click the "Choose File" button and select the file "hello.c1p" +that was created as the output of the above invocation of the "srec_cat" command. Press the "Load" button. You should see the following text on the screen: @@ -581,7 +580,8 @@ Press <RETURN> After hitting the RETURN key you should see the boot prompt again. The program can also be uploaded over the serial port to a real Challenger 1P -computer. +computer with 32 kB RAM. See the <url url="osi.html" name="Ohio Scientifc-specific documentation"> for instructions how to +compile for other RAM sizes. <sect1>Contributions wanted<p> diff --git a/doc/osi.sgml b/doc/osi.sgml index 7152f2815..76c56fac7 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -85,10 +85,10 @@ Special locations: </descrip><p> Example for building a program with start address $0300, stack size -$0200 and RAM size $0200: +$0200 and RAM size $2000: <tscreen> -cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0300 -t osic1p hello.c +cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p hello.c </tscreen> <sect>Linker configurations<p> From fc237faba7182c26faf3e727ddbdde716e813af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sun, 8 Feb 2015 17:12:54 +0100 Subject: [PATCH 51/63] Add missing newline --- libsrc/osic1p/osic1p.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index 4ad0e038b..62178822b 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -2,4 +2,4 @@ SCRNBASE := $D000 ; Base of video RAM VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) INPUTC := $FD00 ; Input character from keyboard -RESET := $FF00 ; Reset address, show boot prompt \ No newline at end of file +RESET := $FF00 ; Reset address, show boot prompt From de3df033d38436a7d780b5d7bec87ab0377d72e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sun, 8 Feb 2015 17:21:23 +0100 Subject: [PATCH 52/63] Remove tabs, fixed accidental insertion of stdio.h. --- src/common/target.c | 2 +- src/common/target.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/target.c b/src/common/target.c index 24734f196..6139c4a39 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -201,7 +201,7 @@ static int Compare (const void* Key, const void* Entry) return strcmp ((const char*) Key, ((const TargetEntry*)Entry)->Name); } -#include <stdio.h> + target_t FindTarget (const char* Name) /* Find a target by name and return the target id. TGT_UNKNOWN is returned if diff --git a/src/common/target.h b/src/common/target.h index edce36fa5..0b50e5060 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -64,8 +64,8 @@ typedef enum { TGT_PLUS4, TGT_CBM510, TGT_CBM610, - TGT_OSIC1P, - TGT_PET, + TGT_OSIC1P, + TGT_PET, TGT_BBC, TGT_APPLE2, TGT_APPLE2ENH, @@ -76,7 +76,7 @@ typedef enum { TGT_NES, TGT_SUPERVISION, TGT_LYNX, - TGT_SIM6502, + TGT_SIM6502, TGT_SIM65C02, TGT_COUNT /* Number of target systems */ } target_t; From 498fbb7ed729c58478c27068d021006471917487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Sun, 8 Feb 2015 17:35:40 +0100 Subject: [PATCH 53/63] Fix formatting, replace tabs with spaces. --- libsrc/osic1p/clrscr.s | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libsrc/osic1p/clrscr.s b/libsrc/osic1p/clrscr.s index 32975526f..48fb5d4f2 100644 --- a/libsrc/osic1p/clrscr.s +++ b/libsrc/osic1p/clrscr.s @@ -13,19 +13,19 @@ BANKS = VIDEORAMSIZE / $100 _clrscr: lda #$20 ;' ' - ldy #BANKS - ldx #$00 + ldy #BANKS + ldx #$00 staloc: - sta SCRNBASE,X - inx - bne staloc - inc staloc+2 - dey - bne staloc - lda #>(SCRNBASE); load high byte - sta staloc+2 ; restore base address + sta SCRNBASE,X + inx + bne staloc + inc staloc+2 + dey + bne staloc + lda #>(SCRNBASE); load high byte + sta staloc+2 ; restore base address - lda #$00 ; cursor in upper left corner + lda #$00 ; cursor in upper left corner sta CURS_X sta CURS_Y - jmp plot ; Set the cursor position + jmp plot ; Set the cursor position From d6a714a0d287b9625e4576a9eb495ac28ab1a8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Wed, 11 Feb 2015 19:14:13 +0100 Subject: [PATCH 54/63] Added Challenger 1P to list of supported machines. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bf7d6dcde..660798128 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ including - the Supervision console. - the Oric Atmos. - the Lynx console. +- the Ohio Scientific Challenger 1P The libraries are fairly portable, so creating a version for other 6502s shouldn't be too much work. From 5063e0eccab745e232c0091cf9d31ca43913ba73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Wed, 11 Feb 2015 19:18:24 +0100 Subject: [PATCH 55/63] Incorporated feedback for initial pull request. --- cfg/osic1p-asm.cfg | 2 +- libsrc/osic1p/osic1p.inc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cfg/osic1p-asm.cfg b/cfg/osic1p-asm.cfg index 57689b96d..d37f17f88 100644 --- a/cfg/osic1p-asm.cfg +++ b/cfg/osic1p-asm.cfg @@ -17,4 +17,4 @@ SEGMENTS { DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; -} \ No newline at end of file +} diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index 62178822b..e364277e0 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -1,5 +1,7 @@ - +; Addresses SCRNBASE := $D000 ; Base of video RAM -VIDEORAMSIZE := $0400 ; Size of C1P video RAM (1 kB) INPUTC := $FD00 ; Input character from keyboard RESET := $FF00 ; Reset address, show boot prompt + +; Other definitions +VIDEORAMSIZE = $0400 ; Size of C1P video RAM (1 kB) From 679f5aa6756a5036e72259aa46fafbe2488610bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Thu, 12 Feb 2015 20:54:47 +0100 Subject: [PATCH 56/63] Use constants for screen width and height. --- cfg/osic1p.cfg | 2 +- libsrc/osic1p/_scrsize.s | 8 +++----- libsrc/osic1p/cputc.s | 4 ++-- libsrc/osic1p/crt0.s | 7 ------- libsrc/osic1p/extzp.inc | 2 +- libsrc/osic1p/extzp.s | 3 +-- libsrc/osic1p/osic1p.inc | 2 ++ 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/cfg/osic1p.cfg b/cfg/osic1p.cfg index 59fdd34d8..4771639a6 100644 --- a/cfg/osic1p.cfg +++ b/cfg/osic1p.cfg @@ -7,7 +7,7 @@ SYMBOLS { } MEMORY { # for size of ZP see runtime/zeropage.s and c1p/extzp.s - ZP: file = "", define = yes, start = $0002, size = $001A + $0006; + ZP: file = "", define = yes, start = $0002, size = $001A + $0005; RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { diff --git a/libsrc/osic1p/_scrsize.s b/libsrc/osic1p/_scrsize.s index 3b0d71c2f..337fe1ee7 100644 --- a/libsrc/osic1p/_scrsize.s +++ b/libsrc/osic1p/_scrsize.s @@ -10,12 +10,10 @@ .export screensize .include "extzp.inc" + .include "osic1p.inc" .proc screensize - - ldx SCR_LINELEN - inx ; Variable is one less - ldy #25 + ldx #(SCR_LINELEN + 1) + ldy #(SCR_HEIGHT + 1) rts - .endproc diff --git a/libsrc/osic1p/cputc.s b/libsrc/osic1p/cputc.s index 9cea78789..f6f285301 100644 --- a/libsrc/osic1p/cputc.s +++ b/libsrc/osic1p/cputc.s @@ -35,7 +35,7 @@ cputdirect: ; Advance cursor position advance: - cpy SCR_LINELEN ; xsize-1 + cpy #SCR_LINELEN ; xsize-1 bne L3 jsr newline ; new line ldy #$FF ; + cr @@ -46,7 +46,7 @@ L3: iny newline: inc CURS_Y lda CURS_Y - cmp #24 ; screen height 25 lines hardcoded + cmp #SCR_HEIGHT ; screen height bne plot lda #0 ; wrap around to line 0 sta CURS_Y diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 447b65c56..0db447bb0 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -28,13 +28,6 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF txs cld ; Clear decimal mode -; --------------------------------------------------------------------------- -; Initialize screen width -; TODO: Can initialization be done in a more idiomatic way? -; TODO: Create function for changing screen width - lda #$18 - sta SCR_LINELEN - ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer diff --git a/libsrc/osic1p/extzp.inc b/libsrc/osic1p/extzp.inc index c5bb2b585..4aab34ff9 100644 --- a/libsrc/osic1p/extzp.inc +++ b/libsrc/osic1p/extzp.inc @@ -4,4 +4,4 @@ ; ------------------------------------------------------------------------ - .globalzp CURS_X, CURS_Y, CURS_SAV, SCR_LINELEN, SCREEN_PTR + .globalzp CURS_X, CURS_Y, CURS_SAV, SCREEN_PTR diff --git a/libsrc/osic1p/extzp.s b/libsrc/osic1p/extzp.s index dfa84a61c..95f9394dc 100644 --- a/libsrc/osic1p/extzp.s +++ b/libsrc/osic1p/extzp.s @@ -14,8 +14,7 @@ CURS_X: .byte 0 CURS_Y: .byte 0 CURS_SAV: .byte 0 -SCR_LINELEN: .byte 24 SCREEN_PTR: .res 2 -; size 6 +; size 5 ; Adjust size of this segment in osic1p.cfg if the size changes diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index e364277e0..58d63632f 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -5,3 +5,5 @@ RESET := $FF00 ; Reset address, show boot prompt ; Other definitions VIDEORAMSIZE = $0400 ; Size of C1P video RAM (1 kB) +SCR_LINELEN = $18 ; screen width - 1 +SCR_HEIGHT = $18 ; screen height - 1 From b1169cbb23030997c87d9abb2d8afb6a2bdc86d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Thu, 12 Feb 2015 21:12:24 +0100 Subject: [PATCH 57/63] Remove unneeded commented code. --- libsrc/osic1p/crt0.s | 2 -- 1 file changed, 2 deletions(-) diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 0db447bb0..07bdc3689 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -38,10 +38,8 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF ; --------------------------------------------------------------------------- ; Initialize memory storage -; copydata seems to be only necessary for special systems jsr zerobss ; Clear BSS segment - ; jsr copydata ; Initialize DATA segment jsr initlib ; Run constructors ; --------------------------------------------------------------------------- From 94f83ea43930ead4e5dab95e0b0a930d3722972a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Thu, 12 Feb 2015 21:29:19 +0100 Subject: [PATCH 58/63] Replace zeropage variable with standard tmp variable. --- cfg/osic1p.cfg | 2 +- libsrc/osic1p/cgetc.s | 5 +++-- libsrc/osic1p/extzp.inc | 2 +- libsrc/osic1p/extzp.s | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cfg/osic1p.cfg b/cfg/osic1p.cfg index 4771639a6..10ce827fd 100644 --- a/cfg/osic1p.cfg +++ b/cfg/osic1p.cfg @@ -7,7 +7,7 @@ SYMBOLS { } MEMORY { # for size of ZP see runtime/zeropage.s and c1p/extzp.s - ZP: file = "", define = yes, start = $0002, size = $001A + $0005; + ZP: file = "", define = yes, start = $0002, size = $001A + $0004; RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S; } SEGMENTS { diff --git a/libsrc/osic1p/cgetc.s b/libsrc/osic1p/cgetc.s index b5a519667..ecd53b8d7 100644 --- a/libsrc/osic1p/cgetc.s +++ b/libsrc/osic1p/cgetc.s @@ -6,6 +6,7 @@ .include "osic1p.inc" .include "extzp.inc" + .include "zeropage.inc" ; Input routine from 65V PROM MONITOR, show cursor if enabled _cgetc: @@ -13,7 +14,7 @@ _cgetc: beq nocursor ldy CURS_X lda (SCREEN_PTR),y ; fetch current character - sta CURS_SAV ; save it + sta tmp1 ; save it lda #$A1 ; full white square sta (SCREEN_PTR),y ; store at cursor position nocursor: @@ -21,7 +22,7 @@ nocursor: pha ; save retrieved character lda cursor ; was cursor on? beq nocursor2 - lda CURS_SAV ; fetch saved character + lda tmp1 ; fetch saved character ldy CURS_X sta (SCREEN_PTR),y ; store at cursor position nocursor2: diff --git a/libsrc/osic1p/extzp.inc b/libsrc/osic1p/extzp.inc index 4aab34ff9..06498d1a6 100644 --- a/libsrc/osic1p/extzp.inc +++ b/libsrc/osic1p/extzp.inc @@ -4,4 +4,4 @@ ; ------------------------------------------------------------------------ - .globalzp CURS_X, CURS_Y, CURS_SAV, SCREEN_PTR + .globalzp CURS_X, CURS_Y, SCREEN_PTR diff --git a/libsrc/osic1p/extzp.s b/libsrc/osic1p/extzp.s index 95f9394dc..e54e2b306 100644 --- a/libsrc/osic1p/extzp.s +++ b/libsrc/osic1p/extzp.s @@ -13,8 +13,7 @@ CURS_X: .byte 0 CURS_Y: .byte 0 -CURS_SAV: .byte 0 SCREEN_PTR: .res 2 -; size 5 +; size 4 ; Adjust size of this segment in osic1p.cfg if the size changes From 5d2e748bd4b7cc7d14b915001f34a43e902c38ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Thu, 12 Feb 2015 21:44:00 +0100 Subject: [PATCH 59/63] Don't use .byte in BSS segments, as value is lost anyway. --- libsrc/osic1p/extzp.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/osic1p/extzp.s b/libsrc/osic1p/extzp.s index e54e2b306..7dc8e3a53 100644 --- a/libsrc/osic1p/extzp.s +++ b/libsrc/osic1p/extzp.s @@ -11,8 +11,8 @@ .segment "EXTZP" : zeropage -CURS_X: .byte 0 -CURS_Y: .byte 0 +CURS_X: .res 1 +CURS_Y: .res 1 SCREEN_PTR: .res 2 ; size 4 From 3601c3fb9b9d62ea0357700d366f168f0b0967be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Thu, 12 Feb 2015 22:12:51 +0100 Subject: [PATCH 60/63] Include "extzp.inc" instead of using direct imports of symbols. --- libsrc/osic1p/clrscr.s | 2 +- libsrc/osic1p/gotox.s | 4 ++-- libsrc/osic1p/gotoxy.s | 2 +- libsrc/osic1p/gotoy.s | 2 +- libsrc/osic1p/wherex.s | 2 +- libsrc/osic1p/wherey.s | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libsrc/osic1p/clrscr.s b/libsrc/osic1p/clrscr.s index 48fb5d4f2..d2346659b 100644 --- a/libsrc/osic1p/clrscr.s +++ b/libsrc/osic1p/clrscr.s @@ -3,7 +3,7 @@ ; .export _clrscr .import plot - .importzp CURS_X, CURS_Y + .include "extzp.inc" .include "osic1p.inc" ; Adapted from the Challenger Character Graphics diff --git a/libsrc/osic1p/gotox.s b/libsrc/osic1p/gotox.s index fb84975d1..0dea72b9a 100644 --- a/libsrc/osic1p/gotox.s +++ b/libsrc/osic1p/gotox.s @@ -6,8 +6,8 @@ ; void gotox (unsigned char x); ; .export _gotox - .import plot - .importzp CURS_X + .import plot + .include "extzp.inc" _gotox: sta CURS_X ; Set new position jmp plot ; And activate it diff --git a/libsrc/osic1p/gotoxy.s b/libsrc/osic1p/gotoxy.s index 32d1f1df2..f76537349 100644 --- a/libsrc/osic1p/gotoxy.s +++ b/libsrc/osic1p/gotoxy.s @@ -8,7 +8,7 @@ ; .export _gotoxy .import popa, plot - .importzp CURS_X, CURS_Y + .include "extzp.inc" _gotoxy: sta CURS_Y ; Set Y diff --git a/libsrc/osic1p/gotoy.s b/libsrc/osic1p/gotoy.s index fcd60dd31..693863d94 100644 --- a/libsrc/osic1p/gotoy.s +++ b/libsrc/osic1p/gotoy.s @@ -7,7 +7,7 @@ ; .export _gotoy .import plot - .importzp CURS_Y + .include "extzp.inc" _gotoy: sta CURS_Y ; Set the new position jmp plot ; And activate it diff --git a/libsrc/osic1p/wherex.s b/libsrc/osic1p/wherex.s index 7c772a5a2..1155a8abd 100644 --- a/libsrc/osic1p/wherex.s +++ b/libsrc/osic1p/wherex.s @@ -5,7 +5,7 @@ ; unsigned char wherex (void); ; .export _wherex - .import CURS_X: zp + .include "extzp.inc" .proc _wherex lda CURS_X diff --git a/libsrc/osic1p/wherey.s b/libsrc/osic1p/wherey.s index 7449c1ceb..632cf4a15 100644 --- a/libsrc/osic1p/wherey.s +++ b/libsrc/osic1p/wherey.s @@ -5,7 +5,7 @@ ; unsigned char wherey (void); ; .export _wherey - .import CURS_Y: zp + .include "extzp.inc" .proc _wherey lda CURS_Y From 88df129215e27233d63afce837b4955ef0a90c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Thu, 12 Feb 2015 22:54:21 +0100 Subject: [PATCH 61/63] Add dummy kbhit(), remove redundant documentation for cgetc(). --- doc/osi.sgml | 4 ++-- libsrc/osic1p/kbhit.s | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 libsrc/osic1p/kbhit.s diff --git a/doc/osi.sgml b/doc/osi.sgml index 76c56fac7..514ef622e 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -139,8 +139,8 @@ There are no loadable drivers available. <sect1>conio implementation<p> -The conio implementation is complete except for the kbhit() function. A -call to cgetc() always blocks until a character is entered. +The conio implementation is complete except for a working kbhit() function. +kbhit() currently returns true unconditionally. <sect1>stdio implementation<p> diff --git a/libsrc/osic1p/kbhit.s b/libsrc/osic1p/kbhit.s new file mode 100644 index 000000000..42db7a5e6 --- /dev/null +++ b/libsrc/osic1p/kbhit.s @@ -0,0 +1,11 @@ +; +; int kbhit (void); +; +; Currently a dummy function that returns always true + + .export _kbhit + +_kbhit: + lda #$01 ; load low byte with true value + ldx #$00 ; load high byte + rts From e178a33d2916ba33fd141c482c77dfef88deafff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Fri, 13 Feb 2015 19:53:02 +0100 Subject: [PATCH 62/63] Fix high byte of return value, optimized. --- libsrc/osic1p/cgetc.s | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libsrc/osic1p/cgetc.s b/libsrc/osic1p/cgetc.s index ecd53b8d7..3c9dd4381 100644 --- a/libsrc/osic1p/cgetc.s +++ b/libsrc/osic1p/cgetc.s @@ -18,13 +18,14 @@ _cgetc: lda #$A1 ; full white square sta (SCREEN_PTR),y ; store at cursor position nocursor: - jsr INPUTC - pha ; save retrieved character - lda cursor ; was cursor on? - beq nocursor2 + 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 -nocursor2: - pla ; restore retrieved character + txa ; restore saved character from X + ldx #$00 ; high byte of int return value +done: rts From 92e75e9df81bde3830b3fc777490177a6c7f1709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= <stephan.muehlstrasser@web.de> Date: Wed, 18 Feb 2015 18:38:42 +0100 Subject: [PATCH 63/63] Incorporated another round of feedback for pull request. Adjusted comment formatting in several assembler files. Removed dummy kbhit() function, as it's better to get a linker error than an implementation that does the wrong thing. --- doc/osi.sgml | 3 +-- libsrc/osic1p/chline.s | 2 +- libsrc/osic1p/clrscr.s | 10 +++++----- libsrc/osic1p/crt0.s | 18 +++++++++--------- libsrc/osic1p/cvline.s | 2 +- libsrc/osic1p/kbhit.s | 11 ----------- libsrc/osic1p/osic1p.inc | 12 ++++++------ 7 files changed, 23 insertions(+), 35 deletions(-) delete mode 100644 libsrc/osic1p/kbhit.s diff --git a/doc/osi.sgml b/doc/osi.sgml index 514ef622e..ce2ee4836 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -139,8 +139,7 @@ There are no loadable drivers available. <sect1>conio implementation<p> -The conio implementation is complete except for a working kbhit() function. -kbhit() currently returns true unconditionally. +The conio implementation is complete except for a kbhit() function. <sect1>stdio implementation<p> diff --git a/libsrc/osic1p/chline.s b/libsrc/osic1p/chline.s index da07e83be..be40d40af 100644 --- a/libsrc/osic1p/chline.s +++ b/libsrc/osic1p/chline.s @@ -22,7 +22,7 @@ _chline: cmp #0 ; Is the length zero? beq L9 ; Jump if done sta tmp1 -L1: lda #$94 ; Horizontal line, screen code +L1: lda #$94 ; Horizontal line, screen code jsr cputdirect ; Direct output dec tmp1 bne L1 diff --git a/libsrc/osic1p/clrscr.s b/libsrc/osic1p/clrscr.s index d2346659b..ee32bf969 100644 --- a/libsrc/osic1p/clrscr.s +++ b/libsrc/osic1p/clrscr.s @@ -12,7 +12,7 @@ BANKS = VIDEORAMSIZE / $100 _clrscr: - lda #$20 ;' ' + lda #$20 ; ' ' ldy #BANKS ldx #$00 staloc: @@ -22,10 +22,10 @@ staloc: inc staloc+2 dey bne staloc - lda #>(SCRNBASE); load high byte - sta staloc+2 ; restore base address + lda #>(SCRNBASE) ; Load high byte + sta staloc+2 ; Restore base address - lda #$00 ; cursor in upper left corner + lda #$00 ; Cursor in upper left corner sta CURS_X sta CURS_Y - jmp plot ; Set the cursor position + jmp plot ; Set the cursor position diff --git a/libsrc/osic1p/crt0.s b/libsrc/osic1p/crt0.s index 07bdc3689..657ee2743 100644 --- a/libsrc/osic1p/crt0.s +++ b/libsrc/osic1p/crt0.s @@ -7,8 +7,8 @@ .export _init, _exit .import _main -.export __STARTUP__ : absolute = 1 ; Mark as startup -.import __RAM_START__, __RAM_SIZE__ ; Linker generated +.export __STARTUP__ : absolute = 1 ; Mark as startup +.import __RAM_START__, __RAM_SIZE__ ; Linker generated .import zerobss, initlib, donelib @@ -24,9 +24,9 @@ ; --------------------------------------------------------------------------- ; A little light 6502 housekeeping -_init: ldx #$FF ; Initialize stack pointer to $01FF +_init: ldx #$FF ; Initialize stack pointer to $01FF txs - cld ; Clear decimal mode + cld ; Clear decimal mode ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer @@ -39,8 +39,8 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF ; --------------------------------------------------------------------------- ; Initialize memory storage - jsr zerobss ; Clear BSS segment - jsr initlib ; Run constructors + jsr zerobss ; Clear BSS segment + jsr initlib ; Run constructors ; --------------------------------------------------------------------------- ; Call main() @@ -48,7 +48,7 @@ _init: ldx #$FF ; Initialize stack pointer to $01FF jsr _main ; --------------------------------------------------------------------------- -; Back from main (this is also the _exit entry): force a software break +; Back from main (this is also the _exit entry): -_exit: jsr donelib ; Run destructors - jmp RESET ; Display boot menu after program exit +_exit: jsr donelib ; Run destructors + jmp RESET ; Display boot menu after program exit diff --git a/libsrc/osic1p/cvline.s b/libsrc/osic1p/cvline.s index c485918ee..84e5a45bf 100644 --- a/libsrc/osic1p/cvline.s +++ b/libsrc/osic1p/cvline.s @@ -21,7 +21,7 @@ _cvline: cmp #0 ; Is the length zero? beq L9 ; Jump if done sta tmp1 -L1: lda #$95 ; Vertical bar +L1: lda #$95 ; Vertical bar jsr putchar ; Write, no cursor advance jsr newline ; Advance cursor to next line dec tmp1 diff --git a/libsrc/osic1p/kbhit.s b/libsrc/osic1p/kbhit.s deleted file mode 100644 index 42db7a5e6..000000000 --- a/libsrc/osic1p/kbhit.s +++ /dev/null @@ -1,11 +0,0 @@ -; -; int kbhit (void); -; -; Currently a dummy function that returns always true - - .export _kbhit - -_kbhit: - lda #$01 ; load low byte with true value - ldx #$00 ; load high byte - rts diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index 58d63632f..9a0c346b6 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -1,9 +1,9 @@ ; Addresses -SCRNBASE := $D000 ; Base of video RAM -INPUTC := $FD00 ; Input character from keyboard -RESET := $FF00 ; Reset address, show boot prompt +SCRNBASE := $D000 ; Base of video RAM +INPUTC := $FD00 ; Input character from keyboard +RESET := $FF00 ; Reset address, show boot prompt ; Other definitions -VIDEORAMSIZE = $0400 ; Size of C1P video RAM (1 kB) -SCR_LINELEN = $18 ; screen width - 1 -SCR_HEIGHT = $18 ; screen height - 1 +VIDEORAMSIZE = $0400 ; Size of C1P video RAM (1 kB) +SCR_LINELEN = $18 ; screen width - 1 +SCR_HEIGHT = $18 ; screen height - 1