1
0
mirror of https://gitlab.com/rnger/amath synced 2025-10-05 18:39:41 +00:00

Cleanup Amiga specific code

This commit is contained in:
2021-01-11 20:59:15 +01:00
parent 9e712377a4
commit 524f83f22f
7 changed files with 80 additions and 56 deletions

View File

@ -269,7 +269,7 @@ typedef u_int64_t uint64_t;
#if defined(WINDOWS) #if defined(WINDOWS)
#define NEWLINE "\r\n" #define NEWLINE "\r\n"
#elif defined(APPLE) #elif defined(APPLE)
#define NEWLINE "\r" #define NEWLINE "\n"
#else #else
#define NEWLINE "\n" #define NEWLINE "\n"
#endif #endif
@ -349,25 +349,4 @@ typedef int bool;
# define TXTSYSMSG TXTCOMPMSG # define TXTSYSMSG TXTCOMPMSG
#endif #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 #endif

View File

@ -39,14 +39,6 @@ const char* vers = TXTDOSVERSION;
class Program* Program = nullptr; class Program* Program = nullptr;
#if defined(AMIGA)
#include <clib/exec_protos.h>
static struct DosBase *DosBase = nullptr;
static struct GfxBase *GfxBase = nullptr;
static struct LocaleBase *LocaleBase = nullptr;
static struct IntuitionBase *IntuitionBase = nullptr;
#endif
/* GCC 2.95 */ /* GCC 2.95 */
#if (__GNUC__ == 2 && __GNUC_MINOR__ == 95) #if (__GNUC__ == 2 && __GNUC_MINOR__ == 95)
void* operator new (size_t size) { return AllocMemSafe(size); } void* operator new (size_t size) { return AllocMemSafe(size); }
@ -112,10 +104,6 @@ int main(int argc, char** argv)
#endif #endif
{ {
#if defined(AMIGA) #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(); Program = new AmigaProgram();
#elif defined(HAIKU) #elif defined(HAIKU)
Program = new HaikuProgram(); Program = new HaikuProgram();
@ -129,20 +117,6 @@ int main(int argc, char** argv)
int exit = Program->GetExitStatus(); 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; delete Program;
FreeAllSafe(); FreeAllSafe();

View File

@ -33,6 +33,8 @@
#include "program.h" #include "program.h"
#include "loc/text.h" #include "loc/text.h"
#define CPROCNAME "amath_console"
static const char *version = TXTVERSMSG; static const char *version = TXTVERSMSG;
static const char *systemName = TXTSYSMSG; static const char *systemName = TXTSYSMSG;
static const char *about = NEWLINE NEWLINE static const char *about = NEWLINE NEWLINE

View File

@ -39,6 +39,12 @@
#if defined(AMIGA) #if defined(AMIGA)
#include <clib/locale_protos.h> #include <clib/locale_protos.h>
#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() : AmigaLanguage::AmigaLanguage() :
Language::Language() Language::Language()
{ {

View File

@ -42,18 +42,51 @@
#include "amiga_arexx.h" #include "amiga_arexx.h"
#if defined(AMIGA) #if defined(AMIGA)
#define ARGS_FORMAT "SHELL/S,NOANSI/S,INPUT/F"
#include <clib/exec_protos.h>
#include <clib/dos_protos.h> #include <clib/dos_protos.h>
#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) #if defined(AOS3)
# define RDPTR LONG* #define RDPTR LONG *
#else #else
# define RDPTR IPTR* #define RDPTR IPTR *
#endif #endif
AmigaProgram::AmigaProgram() AmigaProgram::AmigaProgram()
: Program() : 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; rdargs = nullptr;
args.shell = FALSE; args.shell = FALSE;
args.noansi = FALSE; args.noansi = FALSE;
@ -63,19 +96,45 @@ AmigaProgram::AmigaProgram()
AmigaProgram::~AmigaProgram() AmigaProgram::~AmigaProgram()
{ {
if (Console != nullptr) { if (Console != nullptr)
{
Console->Close(); Console->Close();
delete Console; delete Console;
} }
if (rdargs != nullptr) { if (rdargs != nullptr)
{
FreeArgs(rdargs); 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) 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) if (!rdargs)
{ {
PrintFault(IoErr(), (STRPTR)argv[0]); PrintFault(IoErr(), (STRPTR)argv[0]);
@ -99,7 +158,7 @@ void AmigaProgram::Initialize(int argc, char **argv)
void AmigaProgram::Start() void AmigaProgram::Start()
{ {
if(Console == nullptr || !Console->Open()) if (Console == nullptr || !Console->Open())
{ {
return; return;
} }

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -47,6 +47,10 @@
#include <devices/conunit.h> #include <devices/conunit.h>
#include <devices/console.h> #include <devices/console.h>
#define DEVCONSOLE "console.device"
#define PORTCR "RKM.console.read"
#define PORTCW "RKM.console.write"
AmigaWindow::AmigaWindow(const char *prompt, CharValidator *validator) : AmigaWindow::AmigaWindow(const char *prompt, CharValidator *validator) :
ConsoleBase(prompt) ConsoleBase(prompt)
{ {