diff --git a/src/amath.h b/src/amath.h index a860f195..13bd5eb8 100644 --- a/src/amath.h +++ b/src/amath.h @@ -269,7 +269,7 @@ typedef u_int64_t uint64_t; #if defined(WINDOWS) #define NEWLINE "\r\n" #elif defined(APPLE) -#define NEWLINE "\r" +#define NEWLINE "\n" #else #define NEWLINE "\n" #endif @@ -349,25 +349,4 @@ typedef int bool; # define TXTSYSMSG TXTCOMPMSG #endif /******************************************************************************/ -#define CPROCNAME "amath_console" -/******************************************************************************/ -#if defined(AMIGA) -#define AMIGADOS_NAME "dos.library" -#define AMIGADOS_REV 33L -#define INTUITION_REV 37L -#define INTUITION_NAME "intuition.library" -#define GRAPHICS_REV 37L -#define GRAPHICS_NAME "graphics.library" -#define LOCALE_REV 38L -#define LOCALE_NAME "locale.library" -#define DEVCONSOLE "console.device" -#define PORTCR "RKM.console.read" -#define PORTCW "RKM.console.write" -#define CATALOG_HELP "amath-help.catalog" -#define CATALOG_IDEN "amath-ident.catalog" -#define CATALOG_TEXT "amath-text.catalog" -#define CATALOG_KEYW "amath-keyword.catalog" -#define CATALOG_DEF OC_BuiltInLanguage, "english" -#endif -/******************************************************************************/ #endif diff --git a/src/main.cpp b/src/main.cpp index d095a4c7..4f8c768f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,14 +39,6 @@ const char* vers = TXTDOSVERSION; class Program* Program = nullptr; -#if defined(AMIGA) -#include -static struct DosBase *DosBase = nullptr; -static struct GfxBase *GfxBase = nullptr; -static struct LocaleBase *LocaleBase = nullptr; -static struct IntuitionBase *IntuitionBase = nullptr; -#endif - /* GCC 2.95 */ #if (__GNUC__ == 2 && __GNUC_MINOR__ == 95) void* operator new (size_t size) { return AllocMemSafe(size); } @@ -112,10 +104,6 @@ int main(int argc, char** argv) #endif { #if defined(AMIGA) - DosBase = (struct DosBase*)OpenLibrary(AMIGADOS_NAME, AMIGADOS_REV); - IntuitionBase = (struct IntuitionBase*)OpenLibrary(INTUITION_NAME, INTUITION_REV); - GfxBase = (struct GfxBase*)OpenLibrary(GRAPHICS_NAME, GRAPHICS_REV); - LocaleBase = (struct LocaleBase*)OpenLibrary(LOCALE_NAME, LOCALE_REV); Program = new AmigaProgram(); #elif defined(HAIKU) Program = new HaikuProgram(); @@ -129,20 +117,6 @@ int main(int argc, char** argv) int exit = Program->GetExitStatus(); -#if defined(AMIGA) - if (DosBase != nullptr) - CloseLibrary((struct Library*)DosBase); - - if (LocaleBase != nullptr) - CloseLibrary((struct Library*)LocaleBase); - - if (GfxBase != nullptr) - CloseLibrary((struct Library*)GfxBase); - - if (IntuitionBase != nullptr) - CloseLibrary((struct Library*)IntuitionBase); -#endif - delete Program; FreeAllSafe(); diff --git a/src/system/console.cpp b/src/system/console.cpp index a0a9d0b9..d63e0ac9 100644 --- a/src/system/console.cpp +++ b/src/system/console.cpp @@ -33,6 +33,8 @@ #include "program.h" #include "loc/text.h" +#define CPROCNAME "amath_console" + static const char *version = TXTVERSMSG; static const char *systemName = TXTSYSMSG; static const char *about = NEWLINE NEWLINE diff --git a/src/system/language_amiga.cpp b/src/system/language_amiga.cpp index 19d32763..b473bddb 100644 --- a/src/system/language_amiga.cpp +++ b/src/system/language_amiga.cpp @@ -39,6 +39,12 @@ #if defined(AMIGA) #include +#define CATALOG_HELP "amath-help.catalog" +#define CATALOG_IDEN "amath-ident.catalog" +#define CATALOG_TEXT "amath-text.catalog" +#define CATALOG_KEYW "amath-keyword.catalog" +#define CATALOG_DEF OC_BuiltInLanguage, "english" + AmigaLanguage::AmigaLanguage() : Language::Language() { diff --git a/src/system/program_amiga.cpp b/src/system/program_amiga.cpp index 60bbc60f..5a6173ed 100644 --- a/src/system/program_amiga.cpp +++ b/src/system/program_amiga.cpp @@ -42,18 +42,51 @@ #include "amiga_arexx.h" #if defined(AMIGA) -#define ARGS_FORMAT "SHELL/S,NOANSI/S,INPUT/F" + +#include #include +#ifndef DOSNAME +#define DOSNAME "dos.library" +#endif +#define DOSREV 33L + +#ifndef INTUITIONNAME +#define INTUITIONNAME "intuition.library" +#endif +#define INTUITIONREV 34L + +#ifndef GRAPHICSNAME +#define GRAPHICSNAME "graphics.library" +#endif +#define GRAPHICSREV 34L + +#ifndef LOCALENAME +#define LOCALENAME "locale.library" +#endif +#define LOCALEREV 34L + +static struct DosBase *DosBase = nullptr; +static struct GfxBase *GfxBase = nullptr; +static struct LocaleBase *LocaleBase = nullptr; +static struct IntuitionBase *IntuitionBase = nullptr; + +#define ARGS_FORMAT "SHELL/S,NOANSI/S,INPUT/F" + #if defined(AOS3) -# define RDPTR LONG* +#define RDPTR LONG * #else -# define RDPTR IPTR* +#define RDPTR IPTR * #endif AmigaProgram::AmigaProgram() : Program() { + DosBase = (struct DosBase *)OpenLibrary(DOSNAME, DOSREV); + IntuitionBase = (struct IntuitionBase *)OpenLibrary(INTUITIONNAME, INTUITIONREV); + GfxBase = (struct GfxBase *)OpenLibrary(GRAPHICSNAME, GRAPHICSREV); + LocaleBase = (struct LocaleBase *)OpenLibrary(LOCALENAME, LOCALEREV); + rdargs = nullptr; args.shell = FALSE; args.noansi = FALSE; @@ -63,19 +96,45 @@ AmigaProgram::AmigaProgram() AmigaProgram::~AmigaProgram() { - if (Console != nullptr) { + if (Console != nullptr) + { Console->Close(); delete Console; } - if (rdargs != nullptr) { + if (rdargs != nullptr) + { FreeArgs(rdargs); } + + if (DosBase != nullptr) + CloseLibrary((struct Library *)DosBase); + + if (LocaleBase != nullptr) + CloseLibrary((struct Library *)LocaleBase); + + if (GfxBase != nullptr) + CloseLibrary((struct Library *)GfxBase); + + if (IntuitionBase != nullptr) + CloseLibrary((struct Library *)IntuitionBase); } void AmigaProgram::Initialize(int argc, char **argv) { - rdargs = (RDArgs*)ReadArgs((const char*)ARGS_FORMAT, (RDPTR)&args, 0); + if (DosBase == NULL) + return; + + if (IntuitionBase == NULL) + return; + + if (GfxBase == NULL) + return; + + if (LocaleBase == NULL) + return; + + rdargs = (RDArgs *)ReadArgs((const char *)ARGS_FORMAT, (RDPTR)&args, 0); if (!rdargs) { PrintFault(IoErr(), (STRPTR)argv[0]); @@ -99,7 +158,7 @@ void AmigaProgram::Initialize(int argc, char **argv) void AmigaProgram::Start() { - if(Console == nullptr || !Console->Open()) + if (Console == nullptr || !Console->Open()) { return; } diff --git a/src/system/program_amiga.h b/src/system/program_amiga.h index 10f118da..1896311b 100644 --- a/src/system/program_amiga.h +++ b/src/system/program_amiga.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014-2021 Carsten Sonne Larsen + * Copyright (c) 2014-2018 Carsten Sonne Larsen * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/system/window_amiga.cpp b/src/system/window_amiga.cpp index a2d94c68..3f9802ae 100644 --- a/src/system/window_amiga.cpp +++ b/src/system/window_amiga.cpp @@ -47,6 +47,10 @@ #include #include +#define DEVCONSOLE "console.device" +#define PORTCR "RKM.console.read" +#define PORTCW "RKM.console.write" + AmigaWindow::AmigaWindow(const char *prompt, CharValidator *validator) : ConsoleBase(prompt) {