mirror of
https://gitlab.com/c3d/db48x.git
synced 2024-09-29 05:36:58 +02:00
3bdafe49b5
Some tests fail running out of memory: ``` ../src/tests.cc:2669: Test #21: highp: High-precision computations (60 digits) ../src/tests.cc:2669: 21:045.001: cbrt ../src/tests.cc:2669: Expected output [0.68470 21277 57224 16184 09277 32646 81496 28057 14749 53139 45950 35873 52977 73009 35191 71304 84396 28932 73625 07589 02266 77954 73690 2353], got error [Out of memory] instead ``` Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
212 lines
6.7 KiB
C++
212 lines
6.7 KiB
C++
// ****************************************************************************
|
|
// main.cpp DB48X project
|
|
// ****************************************************************************
|
|
//
|
|
// File Description:
|
|
//
|
|
// DM42 simulator for the DB48 project
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
// ****************************************************************************
|
|
// (C) 2022 Christophe de Dinechin <christophe@dinechin.org>
|
|
// This software is licensed under the terms outlined in LICENSE.txt
|
|
// ****************************************************************************
|
|
// This file is part of DB48X.
|
|
//
|
|
// DB48X is free software: you can redistribute it and/or modify
|
|
// it under the terms outlined in the LICENSE.txt file
|
|
//
|
|
// DB48X is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
// ****************************************************************************
|
|
|
|
#include "object.h"
|
|
#include "recorder.h"
|
|
#include "sim-rpl.h"
|
|
#include "sim-window.h"
|
|
#include "version.h"
|
|
|
|
#include <QApplication>
|
|
#include <QWindow>
|
|
|
|
RECORDER(options, 32, "Information about command line options");
|
|
|
|
bool run_tests = false;
|
|
bool noisy_tests = false;
|
|
bool db48x_keyboard = true;
|
|
uint memory_size = 100; // Memory size in kilobytes
|
|
|
|
size_t recorder_render_object(intptr_t tracing,
|
|
const char *UNUSED /* format */,
|
|
char *buffer, size_t size,
|
|
uintptr_t arg)
|
|
// ----------------------------------------------------------------------------
|
|
// Render a value during a recorder dump (%t format)
|
|
// ----------------------------------------------------------------------------
|
|
{
|
|
object_p value = object_p(arg);
|
|
size_t result = 0;
|
|
if (tracing)
|
|
{
|
|
if (value)
|
|
{
|
|
char tmp[80];
|
|
size_t sz = value->render(tmp, sizeof(tmp)-1);
|
|
tmp[sz] = 0;
|
|
result = snprintf(buffer, size, "%p[%lu] %s[%s]",
|
|
(void *) value,
|
|
value->size(),
|
|
value->fancy(),
|
|
tmp);
|
|
}
|
|
else
|
|
{
|
|
result = snprintf(buffer, size, "0x0 <NULL>");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = snprintf(buffer, size, "%p", (void *) value);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
// Ensure linker keeps debug code
|
|
extern cstring debug();
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
// ----------------------------------------------------------------------------
|
|
// Main entry point for the simulator
|
|
// ----------------------------------------------------------------------------
|
|
{
|
|
const char *traces = getenv("DB48X_TRACES");
|
|
recorder_trace_set(".*(error|warning)s?");
|
|
if (traces)
|
|
recorder_trace_set(traces);
|
|
recorder_dump_on_common_signals(0, 0);
|
|
recorder_configure_type('t', recorder_render_object);
|
|
|
|
// This is just to link otherwise unused code intended for use in debugger
|
|
if (traces && traces[0] == char(0xFF))
|
|
if (cstring result = debug())
|
|
record(options, "Strange input %s", result);
|
|
|
|
// Indicate the first two-byte opcode
|
|
fprintf(stderr,
|
|
"DB48X version %s\n"
|
|
"Last single-byte opcode is %s\n"
|
|
"First two byte opcode is %s\n",
|
|
DB48X_VERSION,
|
|
object::name(object::id(127)),
|
|
object::name(object::id(128)));
|
|
|
|
record(options,
|
|
"Simulator invoked as %+s with %d arguments", argv[0], argc-1);
|
|
for (int a = 1; a < argc; a++)
|
|
{
|
|
record(options, " %u: %+s", a, argv[a]);
|
|
if (argv[a][0] == '-')
|
|
{
|
|
switch(argv[a][1])
|
|
{
|
|
case 't':
|
|
recorder_trace_set(argv[a]+2);
|
|
break;
|
|
case 'n':
|
|
noisy_tests = true;
|
|
break;
|
|
|
|
case 'T':
|
|
run_tests = true;
|
|
// fall-through
|
|
case 'O':
|
|
if (argv[a][2])
|
|
{
|
|
static bool first = true;
|
|
if (first)
|
|
{
|
|
recorder_trace_set("est_.*=0");
|
|
first = false;
|
|
}
|
|
char tname[256];
|
|
if (strcmp(argv[a]+2, "all") == 0)
|
|
strcpy(tname, "est_.*");
|
|
else
|
|
snprintf(tname, sizeof(tname)-1, "est_%s", argv[a]+2);
|
|
recorder_trace_set(tname);
|
|
}
|
|
break;
|
|
case 'D':
|
|
if (argv[a][2])
|
|
tests::dump_on_fail = argv[a]+2;
|
|
else if (a < argc)
|
|
tests::dump_on_fail = argv[++a];
|
|
break;
|
|
|
|
case 'k':
|
|
db48x_keyboard = true;
|
|
break;
|
|
case 'w':
|
|
if (argv[a][2])
|
|
tests::default_wait_time = atoi(argv[a]+2);
|
|
else if (a < argc)
|
|
tests::default_wait_time = atoi(argv[++a]);
|
|
break;
|
|
case 'd':
|
|
if (argv[a][2])
|
|
tests::key_delay_time = atoi(argv[a]+2);
|
|
else if (a < argc)
|
|
tests::key_delay_time = atoi(argv[++a]);
|
|
break;
|
|
case 'r':
|
|
if (argv[a][2])
|
|
tests::refresh_delay_time = atoi(argv[a]+2);
|
|
else if (a < argc)
|
|
tests::refresh_delay_time = atoi(argv[++a]);
|
|
break;
|
|
case 'i':
|
|
if (argv[a][2])
|
|
tests::image_wait_time = atoi(argv[a]+2);
|
|
else if (a < argc)
|
|
tests::image_wait_time = atoi(argv[++a]);
|
|
break;
|
|
case 'm':
|
|
if (argv[a][2])
|
|
memory_size = atoi(argv[a]+2);
|
|
else if (a < argc)
|
|
memory_size = atoi(argv[++a]);
|
|
break;
|
|
case 's':
|
|
if (argv[a][2])
|
|
MainWindow::devicePixelRatio = atof(argv[a]+2);
|
|
else if (a < argc)
|
|
MainWindow::devicePixelRatio = atof(argv[++a]);
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#if QT_VERSION < 0x060000
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
#endif // QT version 6
|
|
|
|
QCoreApplication::setOrganizationName("DB48X Project");
|
|
QCoreApplication::setOrganizationDomain("48calc.org");
|
|
QCoreApplication::setApplicationName("DB48X");
|
|
|
|
QApplication a(argc, argv);
|
|
MainWindow w;
|
|
w.show();
|
|
|
|
return a.exec();
|
|
}
|