mirror of
https://gitlab.com/rnger/amath
synced 2025-10-05 02:19:17 +00:00
Cleanup Amiga specific code
This commit is contained in:
23
src/amath.h
23
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
|
||||
|
26
src/main.cpp
26
src/main.cpp
@ -39,14 +39,6 @@ const char* vers = TXTDOSVERSION;
|
||||
|
||||
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 */
|
||||
#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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -39,6 +39,12 @@
|
||||
#if defined(AMIGA)
|
||||
#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() :
|
||||
Language::Language()
|
||||
{
|
||||
|
@ -42,18 +42,51 @@
|
||||
#include "amiga_arexx.h"
|
||||
|
||||
#if defined(AMIGA)
|
||||
#define ARGS_FORMAT "SHELL/S,NOANSI/S,INPUT/F"
|
||||
|
||||
#include <clib/exec_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)
|
||||
# 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;
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,10 @@
|
||||
#include <devices/conunit.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) :
|
||||
ConsoleBase(prompt)
|
||||
{
|
||||
|
Reference in New Issue
Block a user