Cleanup stage 2

This commit is contained in:
Heath123
2023-05-05 20:16:51 +01:00
parent d72ca852a6
commit b3e6d4337a
52 changed files with 255 additions and 698 deletions

View File

@@ -127,6 +127,7 @@ ifndef USE_LIBA
endif
ifeq ($(USE_LIBA),0)
include liba/Makefile.bridge
include libaxx/Makefile.bridge
else
SFLAGS += -ffreestanding -nostdinc -nostdlib
include liba/Makefile

View File

@@ -270,7 +270,7 @@ void ContinuousFunction::rangeForDisplay(float * xMin, float * xMax, float * yMi
}
if (!basedOnCostlyAlgorithms(context)) {
Zoom::ValueAtAbscissa evaluation = [](float x, Context * context, const void * auxiliary) {
Zoom::ValueAtAbscissa evaluation = [](float x, Context * context, const void * auxiliary) -> float {
/* When evaluating sin(x)/x close to zero using the standard sine function,
* one can detect small variations, while the cardinal sine is supposed to be
* locally monotonous. To smooth our such variations, we round the result of

View File

@@ -82,7 +82,6 @@ protected:
void setActive(bool active) { m_active = active; }
private:
#if __EMSCRIPTEN__
// TODO: Fix on Casio
/* For emscripten memory representation, loads and stores must be aligned;
* performing a normal load or store on an unaligned address can fail
* silently. We thus use 'emscripten_align1_short' type, the unaligned

View File

@@ -78,7 +78,7 @@ protected:
* So normalizedYHalfRange = 43.2mm * 170/240 * 1 unit / 10.0mm */
constexpr static float NormalizedYHalfRange(float unit) { return 3.06f * unit; }
bool shouldBeNormalized() const;
virtual bool hasDefaultRange() const { return (xMin() == round(xMin())) && (xMax() == round(xMax())); }
virtual bool hasDefaultRange() const { return (xMin() == std::round(xMin())) && (xMax() == std::round(xMax())); }
InteractiveCurveViewRangeDelegate * m_delegate;
private:

View File

@@ -33,7 +33,6 @@ public:
static float defaultRangeLengthFor(float position);
private:
#if __EMSCRIPTEN__
// TODO: Fix on Casio
// See comment about emscripten alignment in Shared::Function::RecordDataBuffer
static_assert(sizeof(emscripten_align1_short) == sizeof(uint16_t), "emscripten_align1_short should have the same size as uint16_t");
emscripten_align1_float m_min;

View File

@@ -108,7 +108,6 @@ private:
Type m_type;
uint8_t m_initialRank;
#if __EMSCRIPTEN__
// TODO: Fix on Casio
// See comment about emscripten alignment in Shared::Function::RecordDataBuffer
static_assert(sizeof(emscripten_align1_short) == sizeof(uint16_t), "emscripten_align1_short should have the same size as uint16_t");
emscripten_align1_short m_initialConditionSizes[2];

View File

@@ -2,7 +2,7 @@ USE_LIBA = 0
ION_KEYBOARD_LAYOUT = layout_B2
EPSILON_GETOPT = 1
# SFLAGS += -fPIE
SFLAGS += -fPIE
TARGET ?= $(HOST)

View File

@@ -1,4 +1,4 @@
TOOLCHAIN = sh3eb-elf-gcc
TOOLCHAIN = sh-elf-gcc
EXE = bin
EPSILON_TELEMETRY ?= 0
@@ -7,3 +7,5 @@ HANDY_TARGETS_EXTENSIONS = bin
USE_LIBA = 0
POINCARE_TREE_LOG = 0
SFLAGS := $(filter-out -fPIE, $(SFLAGS))

View File

@@ -1,8 +1,7 @@
#include "kandinsky/color.h"
#include <cstdint>
#include <escher/icon_view.h>
extern "C" {
#include <assert.h>
#include <stdint.h>
}
#include <ion.h>
#include <kandinsky.h>

View File

@@ -1,7 +1,7 @@
#include <cstdint>
#include <escher/image_view.h>
extern "C" {
#include <assert.h>
#include <stdint.h>
}
#include <ion.h>

View File

@@ -3,7 +3,6 @@
extern "C" {
#include <assert.h>
#include <stdio.h>
}
#include <algorithm>

View File

@@ -1,174 +0,0 @@
#include <stddef.h>
// https://android.googlesource.com/platform/system/core.git/+/master/libcutils/strlcpy.c
inline size_t strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0) {
while (--n != 0) {
if ((*d++ = *s++) == '\0')
break;
}
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
}
#include <math.h>
// If using C++
#ifdef __cplusplus
extern "C++" {
namespace std {
// functions
using ::acosh;
using ::acoshf;
using ::acoshl;
using ::asinh;
using ::asinhf;
using ::asinhl;
using ::atanh;
using ::atanhf;
using ::atanhl;
using ::cbrt;
using ::cbrtf;
using ::cbrtl;
using ::copysign;
using ::copysignf;
using ::copysignl;
using ::erf;
using ::erff;
using ::erfl;
using ::erfc;
using ::erfcf;
using ::erfcl;
using ::exp2;
using ::exp2f;
using ::exp2l;
using ::expm1;
using ::expm1f;
using ::expm1l;
using ::fdim;
using ::fdimf;
using ::fdiml;
using ::fma;
using ::fmaf;
using ::fmal;
using ::fmax;
using ::fmaxf;
using ::fmaxl;
using ::fmin;
using ::fminf;
using ::fminl;
using ::hypot;
using ::hypotf;
using ::hypotl;
using ::ilogb;
using ::ilogbf;
using ::ilogbl;
using ::lgamma;
using ::lgammaf;
using ::lgammal;
using ::llrint;
using ::llrintf;
using ::llrintl;
using ::llround;
using ::llroundf;
using ::llroundl;
using ::log1p;
using ::log1pf;
using ::log1pl;
using ::log2;
using ::log2f;
using ::log2l;
using ::logb;
using ::logbf;
using ::logbl;
using ::lrint;
using ::lrintf;
using ::lrintl;
using ::lround;
using ::lroundf;
using ::lroundl;
using ::nan;
using ::nanf;
using ::nanl;
using ::nearbyint;
using ::nearbyintf;
using ::nearbyintl;
using ::nextafter;
using ::nextafterf;
using ::nextafterl;
using ::nexttoward;
using ::nexttowardf;
using ::nexttowardl;
using ::remainder;
using ::remainderf;
using ::remainderl;
using ::remquo;
using ::remquof;
using ::remquol;
using ::rint;
using ::rintf;
using ::rintl;
using ::round;
using ::roundf;
using ::roundl;
using ::scalbln;
using ::scalblnf;
using ::scalblnl;
using ::scalbn;
using ::scalbnf;
using ::scalbnl;
using ::tgamma;
using ::tgammaf;
using ::tgammal;
using ::trunc;
using ::truncf;
using ::truncl;
}
}
#endif

View File

@@ -1,40 +0,0 @@
/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _ALLOCA_H
#define _ALLOCA_H 1
// #include <features.h>
#define __need_size_t
#include <stddef.h>
// __BEGIN_DECLS
/* Remove any previous definition. */
#undef alloca
/* Allocate a block that will be freed when the calling function exits. */
// extern void *alloca (size_t __size) __THROW;
// #ifdef __GNUC__
# define alloca(size) __builtin_alloca (size)
// #endif /* GCC. */
// __END_DECLS
#endif /* alloca.h */

View File

@@ -23,8 +23,15 @@ void pullRect(KDRect r, KDColor * pixels);
bool waitForVBlank();
#ifndef _PRIZM
constexpr int Width = 320;
constexpr int Height = 240;
#else
constexpr int Width = 396;
constexpr int Height = 224;
#endif
// TODO: Adjust this on the Casio calculator
constexpr int WidthInTenthOfMillimeter = 576;
constexpr int HeightInTenthOfMillimeter = 432;

View File

@@ -1,8 +0,0 @@
#ifndef LIBA_STRINGS_H
#define LIBA_STRINGS_H
#include <stdlib.h>
void bzero(void * s, size_t n);
#endif

View File

@@ -1,4 +1,4 @@
#include "ion/keyboard.h"
#include <ion/keyboard.h>
#include <ion/events.h>
#include <ion/timing.h>
#include <assert.h>
@@ -86,7 +86,7 @@ static inline Event innerGetEvent(int * timeout) {
bool shift = isShiftActive() || state.keyDown(Keyboard::Key::Shift);
bool alpha = isAlphaActive() || state.keyDown(Keyboard::Key::Alpha);
// Allow the detectec states to be overriden by the simulated states
// Allow the detected states to be overriden by the simulated states
// This is used for key mapping
if (state.simulatedShift() != Keyboard::ModSimState::None) {
shift = state.simulatedShift() == Keyboard::ModSimState::ForceOn;

View File

@@ -1,3 +1,2 @@
undefine sdl_src
undefine ion_simulator_sdl_src

View File

@@ -8,8 +8,6 @@ SFLAGS += -DUSING_GENERATED_CONFIG_H
# which is added later on in the SDL Makefile
SFLAGS += -Iion/src/simulator/linux/include
# SFLAGS += -D_BIG_ENDIAN
ion_src += $(addprefix ion/src/simulator/linux/, \
assets.s \
platform_files.cpp \
@@ -26,14 +24,14 @@ ion_src += $(addprefix ion/src/simulator/shared/, \
dummy/window_callback.cpp \
actions.cpp \
clipboard_helper.cpp \
collect_registers_x86_64.s \
collect_registers.cpp \
haptics.cpp \
journal.cpp \
state_file.cpp \
store_script.cpp \
)
ion_src += ion/src/shared/collect_registers.cpp
ifeq ($(EPSILON_TELEMETRY),1)
ion_src += ion/src/simulator/shared/dummy/telemetry_init.cpp
ion_src += ion/src/shared/telemetry_console.cpp

View File

@@ -10,10 +10,14 @@ ion_src += $(addprefix ion/src/simulator/prizm/, \
events.cpp \
timing.cpp \
console.cpp \
atexit.c \
backlight.cpp \
)
liba_src += $(addprefix liba/src/, \
strlcat.c \
strlcpy.c \
)
ion_src += ion/src/shared/collect_registers.cpp
sdl_simu_needs_to_be_removed += $(addprefix ion/src/simulator/shared/, \
@@ -49,27 +53,5 @@ ion_src := $(filter-out $(sdl_simu_needs_to_be_removed),$(ion_src))
SFLAGS := $(filter-out -Iion/src/simulator/external/sdl/include,$(SFLAGS))
SFLAGS += -DFXCG50 -DTARGET_FXCG50 -m4-nofpu -mb -ffreestanding -nostdlib -Wa,--dsp -fstrict-volatile-bitfields
LDFLAGS += -nostdlib -Wl,--no-warn-rwx-segments -T fxcg50_fastload.ld /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libgint-cg.a /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libc.a /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libgint-cg.a /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libc.a -lgcc -lopenlibm -lstdc++
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
#define M_LN2 0.69314718055994530942 /* log e2 */
#define M_LN10 2.30258509299404568402 /* log e10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
SFLAGS += -DM_E=2.7182818284590452354 -DM_LOG2E=1.4426950408889634074 -DM_LOG10E=0.43429448190325182765 -DM_LN2=0.69314718055994530942 -DM_LN10=2.30258509299404568402 -DM_PI=3.14159265358979323846 -DM_PI_2=1.57079632679489661923 -DM_PI_4=0.78539816339744830962 -DM_1_PI=0.31830988618379067154 -DM_2_PI=0.63661977236758134308 -DM_2_SQRTPI=1.12837916709551257390 -DM_SQRT2=1.41421356237309504880 -DM_SQRT1_2=0.70710678118654752440
SFLAGS += -include headers/include.h
# TODO: THis is bad, remove it and fix the code.
SFLAGS += -fpermissive
SFLAGS += -fno-use-cxa-atexit -gdwarf-5
LDFLAGS += -gdwarf-5
SFLAGS += -DFXCG50 -DTARGET_FXCG50 -m4-nofpu -mb -ffreestanding -nostdlib -Wa,--dsp -fstrict-volatile-bitfields -g
LDFLAGS += -nostdlib -Wl,--no-warn-rwx-segments -T fxcg50_fastload.ld -lgint-cg -lc -lgint-cg -lc -lgcc -lopenlibm -lstdc++

View File

@@ -1,3 +0,0 @@
int atexit(void (*func)(void)) {
return 0;
}

View File

@@ -5,9 +5,9 @@
// From gint:
/* Interface with the controller */
static volatile uint16_t *intf = (void *)0xb4000000;
static volatile uint16_t *intf = (uint16_t *)0xb4000000;
/* Bit 4 of Port R controls the RS bit of the display driver */
static volatile uint8_t *PRDR = (void *)0xa405013c;
static volatile uint8_t *PRDR = (uint8_t *)0xa405013c;
GINLINE static void select(uint16_t reg)
{

View File

@@ -1,6 +1,6 @@
#include "display.h"
#include "framebuffer.h"
#include "kandinsky/color.h"
#include <kandinsky/color.h>
#include <cstdint>
#include <gint/display-cg.h>
#include <ion/display.h>
@@ -16,84 +16,13 @@ namespace Simulator {
namespace Display {
void init() {
// lcd_init(SCR_320x240_565);
}
void quit() {
// lcd_init(SCR_TYPE_INVALID);
}
static int draw_count = 0;
void draw() {
// if (draw_count == 0) {
// dclear(C_RED);
// dupdate();
// }
// TODO: dupdate here
/* static const bool has_colors_cache = has_colors;
if (has_colors_cache) {
// same as lcd_blit((void*)Framebuffer::address(), SCR_320x240_565)
memcpy(REAL_SCREEN_BASE_ADDRESS, (void*)Framebuffer::address(), 320 * 240 * sizeof(uint16_t));
} else { // invert screen color if running on classic
for (unsigned int i = 0; i < 320 * 240; i++) {
reinterpret_cast<uint16_t*>(REAL_SCREEN_BASE_ADDRESS)[i] = 0xFFFF - Framebuffer::address()[i];
}
} */
// Loop over all the pixels and plot them
// for (int x = 0; x < Ion::Display::Width; x++) {
// for (int y = 0; y < /* Ion::Display::Height */ 224; y++) {
// // Get the color of the pixel
// KDColor color = Framebuffer::address()[x + y * Ion::Display::Width];
// // Plot the pixel
// dpixel(x, y, color);
// }
// }
// dupdate();
// Faster implementation: Use memcpy to copy each line to gint_vram
// for (int y = 0; y < /* Ion::Display::Height */ 224; y++) {
// memcpy(gint_vram + (y * 396), Framebuffer::address() + y * Ion::Display::Width, Ion::Display::Width * sizeof(uint16_t));
// }
dupdate();
// printf("draw\n");
// draw_count++;
// if (draw_count == 10) {
// // printf("draw_count == 10\n");
// dclear(C_GREEN);
// dtext(1, 16, C_BLACK, "draw_count == 10");
// const KDColor* pixels = Framebuffer::address();
// // Loop over all the pixels excluding the status bar
// // It is 18 pixels high
// // Add all their values to a counter as some kind of hash
// uint64_t hash = 0;
// for (int y = 18; y < 240; y++) {
// for (int x = 0; x < 320; x++) {
// hash += pixels[y * 320 + x];
// }
// }
// // printf("hash: %lu\n", hash);
// if (hash == 4352844898) {
// // printf("SUCCESS\n");
// dtext(1, 32, C_BLACK, "SUCCESS");
// } else {
// // printf("FAILURE\n");
// dtext(1, 32, C_BLACK, "FAILURE");
// }
// dupdate();
// while (true) {
// getkey();
// }
// // Framebuffer::writeToFile("test.bin");
// }
}
}

View File

@@ -2,7 +2,6 @@
#define ION_SIMULATOR_DISPLAY_H
#include <kandinsky.h>
// #include <n2DLib.h>
namespace Ion {
namespace Simulator {

View File

@@ -1,62 +1,4 @@
#include "main.h"
#include "keyboard.h"
#include "platform.h"
//#include "driver/common.h"
// #include <libndls.h>
// #include <n2DLib.h>
#include "events.h"
#include <assert.h>
#include <ion/events.h>
#include <string.h>
// class AlphaKeyPair {
// public:
// constexpr AlphaKeyPair(char key, char shiftAlphaKey, t_key ndlessKey) :
// m_key(key),
// m_shiftAlphaKey(shiftAlphaKey),
// m_ndlessKey(ndlessKey)
// {}
// char key() const { return m_key; }
// char shiftAlphaKey() const { return m_shiftAlphaKey; }
// t_key ndlessKey() const { return m_ndlessKey; }
// private:
// char m_key;
// char m_shiftAlphaKey;
// t_key m_ndlessKey;
// // };
// constexpr static AlphaKeyPair aKeyPairs[] = {
// AlphaKeyPair('a', 'A', KEY_NSPIRE_A),
// AlphaKeyPair('b', 'B', KEY_NSPIRE_B),
// AlphaKeyPair('c', 'C', KEY_NSPIRE_C),
// AlphaKeyPair('d', 'D', KEY_NSPIRE_D),
// AlphaKeyPair('e', 'E', KEY_NSPIRE_E),
// AlphaKeyPair('f', 'F', KEY_NSPIRE_F),
// AlphaKeyPair('g', 'G', KEY_NSPIRE_G),
// AlphaKeyPair('h', 'H', KEY_NSPIRE_H),
// AlphaKeyPair('i', 'I', KEY_NSPIRE_I),
// AlphaKeyPair('j', 'J', KEY_NSPIRE_J),
// AlphaKeyPair('k', 'K', KEY_NSPIRE_K),
// AlphaKeyPair('l', 'L', KEY_NSPIRE_L),
// AlphaKeyPair('m', 'M', KEY_NSPIRE_M),
// AlphaKeyPair('n', 'N', KEY_NSPIRE_N),
// AlphaKeyPair('o', 'O', KEY_NSPIRE_O),
// AlphaKeyPair('p', 'P', KEY_NSPIRE_P),
// AlphaKeyPair('q', 'Q', KEY_NSPIRE_Q),
// AlphaKeyPair('r', 'R', KEY_NSPIRE_R),
// AlphaKeyPair('s', 'S', KEY_NSPIRE_S),
// AlphaKeyPair('t', 'T', KEY_NSPIRE_T),
// AlphaKeyPair('u', 'U', KEY_NSPIRE_U),
// AlphaKeyPair('v', 'V', KEY_NSPIRE_V),
// AlphaKeyPair('w', 'W', KEY_NSPIRE_W),
// AlphaKeyPair('x', 'X', KEY_NSPIRE_X),
// AlphaKeyPair('y', 'Y', KEY_NSPIRE_Y),
// AlphaKeyPair('z', 'Z', KEY_NSPIRE_Z),
// AlphaKeyPair(' ', ' ', KEY_NSPIRE_SPACE)
// };
// constexpr int aNumberOfKeyPairs = sizeof(aKeyPairs)/sizeof(AlphaKeyPair);
namespace Ion {
namespace Events {
@@ -64,41 +6,6 @@ namespace Events {
Event getPlatformEvent() {
Event result = None;
// t_key scanResult;
// static t_key prevScanResult = {_KEY_DUMMY_ROW, _KEY_DUMMY_COL, _KEY_DUMMY_ROW, _KEY_DUMMY_COL, TPAD_ARROW_NONE};
// static bool keyDown = false;
// bool getKeyResult = get_key_pressed(&scanResult);
// if (getKeyResult) {
// if (isKey(scanResult, KEY_NSPIRE_SCRATCHPAD)) { // 'Quit' bound to 'Scratchpad'
// return Termination;
// }
// if (!isKey(scanResult, prevScanResult)) {
// keyDown = false;
// prevScanResult = scanResult;
// }
// if (!keyDown && !Simulator::Keyboard::scanHandlesKey(scanResult)) { // handle alphabetical keypad press
// keyDown = true;
// for (int i = 0; i < aNumberOfKeyPairs; i++) {
// if (isKey(scanResult, aKeyPairs[i].ndlessKey())) {
// //strlcpy(sharedExternalTextBuffer(), aKeyPairs[i].key(), sharedExternalTextBufferSize);
// if (Ion::Events::isShiftActive() && Ion::Events::isAlphaActive()) {
// sharedExternalTextBuffer()[0] = aKeyPairs[i].shiftAlphaKey();
// if (!Ion::Events::isLockActive()) Ion::Events::removeShift();
// } else {
// sharedExternalTextBuffer()[0] = aKeyPairs[i].key();
// }
// sharedExternalTextBuffer()[1] = '\0';
// return ExternalText;
// }
// }
// }
// } else keyDown = false;
return result;
}

View File

@@ -51,19 +51,6 @@ void setActive(bool enabled) {
sFrameBufferActive = enabled;
}
void writeToFile(const char * filename) {
// // Write as a raw RGB565 file
// FILE * f = fopen(filename, "wb");
// if (f == NULL) {
// return;
// }
// for (int i = 0; i < Ion::Display::Width * Ion::Display::Height; i++) {
// uint16_t color = sPixels[i];
// fwrite(&color, 2, 1, f);
// }
// fclose(f);
}
}
}
}

View File

@@ -9,7 +9,6 @@ namespace Framebuffer {
const KDColor * address();
void setActive(bool enabled);
void writeToFile(const char * filename);
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -1,28 +0,0 @@
# Convert the raw 320 * 240 RGB565 data in test.bin to a PNG image
from PIL import Image
# Open the raw data file
with open('test.bin', 'rb') as f:
# Read the raw data
data = f.read()
# Create a new image
img = Image.new('RGB', (320, 240))
# Convert the raw data to RGB565 and save it to the image
for y in range(240):
for x in range(320):
# Read 2 bytes from the raw data
b = data[(y * 320 + x) * 2 : (y * 320 + x) * 2 + 2]
# Convert the 2 bytes to an integer
i = int.from_bytes(b, 'little')
# Convert the RGB565 to RGB888
r = ((i >> 11) & 0x1F) << 3
g = ((i >> 5) & 0x3F) << 2
b = (i & 0x1F) << 3
# Save the RGB888 to the image
img.putpixel((x, y), (r, g, b))
# Save the image to a PNG file
img.save('test.png')

View File

@@ -4,10 +4,8 @@
#include <gint/display.h>
#include <gint/keycodes.h>
#include <ion/keyboard.h>
// #include <libndls.h>
// #include <n2DLib.h>
#include "ion/events.h"
#include <ion/events.h>
#include "keyboard.h"
#include "layout_keyboard.h"
#include "main.h"
@@ -243,15 +241,6 @@ namespace Ion {
namespace Simulator {
namespace Keyboard {
// bool scanHandlesKey(t_key key) {
// for (int i = 0; i < sNumberOfKeyPairs; i++) {
// if (isKey(key, sKeyPairs[i].ndlessKey())) {
// return true;
// }
// }
// return false;
// }
}
}
}

View File

@@ -8,8 +8,6 @@ namespace Ion {
namespace Simulator {
namespace Keyboard {
// bool scanHandlesKey(t_key key);
}
}
}

View File

@@ -1,2 +0,0 @@
cd /home/heath/omega-prizm-2/Omega
sh-elf-g++ output/release/simulator/prizm/ion/src/simulator/prizm/main.o -nostdlib -Wl,--no-warn-rwx-segments -T fxcg50.ld /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libgint-cg.a /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libc.a /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libgint-cg.a /home/heath/.local/share/fxsdk/sysroot/sh3eb-elf/lib/libc.a -lgcc -lopenlibm -lstdc++ -o output/release/simulator/prizm/epsilon.bin

View File

@@ -11,25 +11,11 @@
#include <ion.h>
#include <ion/events.h>
// #include <n2DLib.h>
// #include <libndls.h>
#include <gint/display.h>
#include <gint/keyboard.h>
//#include "driver/common.h"
extern "C" {
int main() {
// printf("Hello, world!\n");
dclear(C_WHITE);
Ion::Simulator::Main::init();
ion_main(0, NULL);
dtext(1, 32, C_BLACK, "Simulator done!");
dupdate();
getkey();
Ion::Simulator::Main::quit();
return 0;
@@ -43,29 +29,7 @@ namespace Main {
static bool sNeedsRefresh = false;
void init() {
//Ion::Simulator::CommonDriver::init();
// Ion::Simulator::Display::init();
// relayout(); TODO: I assume this was part of Ndless?
}
void relayout() {
int windowWidth = 320;
int windowHeight = 240;
// Keep original aspect ration in screen_only mode.
/*
float scale = (float)(Ion::Display::Width) / (float)(Ion::Display::Height);
if ((float)(windowHeight) * scale > float(windowWidth)) {
sScreenRect.w = windowWidth;
sScreenRect.h = (int)((float)(windowWidth) / scale);
} else {
sScreenRect.w = (int)((float)(windowHeight) * scale);
sScreenRect.h = windowHeight;
}
sScreenRect.x = (windowWidth - sScreenRect.w) / 2;
sScreenRect.y = (windowHeight - sScreenRect.h) / 2;
*/
Ion::Simulator::Display::init();
setNeedsRefresh();
}
@@ -84,23 +48,9 @@ void refresh() {
}
void quit() {
//Ion::Simulator::CommonDriver::deinit();
// Ion::Simulator::Display::quit();
Ion::Simulator::Display::quit();
}
}
}
}
// #include <gint/display.h>
// #include <gint/keyboard.h>
// int main(void)
// {
// dclear(C_WHITE);
// dtext(1, 1, C_BLACK, "Sample fxSDK add-in.");
// dupdate();
// getkey();
// return 1;
// }

View File

@@ -10,7 +10,6 @@ void quit();
void setNeedsRefresh();
void refresh();
void relayout();
}
}

File diff suppressed because one or more lines are too long

View File

@@ -13,9 +13,6 @@ namespace Timing {
uint64_t millis() {
auto elapsed = std::chrono::steady_clock::now() - start;
return std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
// Dummy implementation
// return 0;
}
void usleep(uint32_t us) {

View File

@@ -1,4 +1,4 @@
#include "kandinsky/color.h"
#include <kandinsky/color.h>
#include <cstdint>
#include <kandinsky/postprocess_gamma_context.h>
#include <ion.h>

View File

@@ -0,0 +1,20 @@
#ifndef LIBA_BRIDGE_MATH_H
#define LIBA_BRIDGE_MATH_H
#include_next <math.h>
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
#define M_LN2 0.69314718055994530942 /* log e2 */
#define M_LN10 2.30258509299404568402 /* log e10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif

View File

@@ -7,7 +7,7 @@
LIBA_BEGIN_DECLS
#if (__GLIBC__ || __MINGW32__)
#if (__GLIBC__ || __MINGW32__ || _PRIZM)
size_t strlcat(char * dst, const char * src, size_t dstSize);
size_t strlcpy(char * dst, const char * src, size_t len);
#endif

View File

@@ -0,0 +1,22 @@
#ifndef LIBA_STRINGS_H
#define LIBA_STRINGS_H
#if (_PRIZM)
#include <stdlib.h>
#include "../private/macros.h"
LIBA_BEGIN_DECLS
void bzero(void * s, size_t n);
LIBA_END_DECLS
#else
#include_next <strings.h>
#endif
#endif

3
libaxx/Makefile.bridge Normal file
View File

@@ -0,0 +1,3 @@
SFLAGS += -Ilibaxx/include/bridge
# libaxx_src += libaxx/src/bridge.c

165
libaxx/include/bridge/cmath Normal file
View File

@@ -0,0 +1,165 @@
#ifndef LIBA_BRIDGE_CMATH_H
#define LIBA_BRIDGE_CMATH_H
#include_next <cmath>
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
#define M_LN2 0.69314718055994530942 /* log e2 */
#define M_LN10 2.30258509299404568402 /* log e10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#if (_PRIZM)
namespace std {
// functions
using ::acosh;
using ::acoshf;
using ::acoshl;
using ::asinh;
using ::asinhf;
using ::asinhl;
using ::atanh;
using ::atanhf;
using ::atanhl;
using ::cbrt;
using ::cbrtf;
using ::cbrtl;
using ::copysign;
using ::copysignf;
using ::copysignl;
using ::erf;
using ::erff;
using ::erfl;
using ::erfc;
using ::erfcf;
using ::erfcl;
using ::exp2;
using ::exp2f;
using ::exp2l;
using ::expm1;
using ::expm1f;
using ::expm1l;
using ::fdim;
using ::fdimf;
using ::fdiml;
using ::fma;
using ::fmaf;
using ::fmal;
using ::fmax;
using ::fmaxf;
using ::fmaxl;
using ::fmin;
using ::fminf;
using ::fminl;
using ::hypot;
using ::hypotf;
using ::hypotl;
using ::ilogb;
using ::ilogbf;
using ::ilogbl;
using ::lgamma;
using ::lgammaf;
using ::lgammal;
using ::llrint;
using ::llrintf;
using ::llrintl;
using ::llround;
using ::llroundf;
using ::llroundl;
using ::log1p;
using ::log1pf;
using ::log1pl;
using ::log2;
using ::log2f;
using ::log2l;
using ::logb;
using ::logbf;
using ::logbl;
using ::lrint;
using ::lrintf;
using ::lrintl;
using ::lround;
using ::lroundf;
using ::lroundl;
using ::nan;
using ::nanf;
using ::nanl;
using ::nearbyint;
using ::nearbyintf;
using ::nearbyintl;
using ::nextafter;
using ::nextafterf;
using ::nextafterl;
using ::nexttoward;
using ::nexttowardf;
using ::nexttowardl;
using ::remainder;
using ::remainderf;
using ::remainderl;
using ::remquo;
using ::remquof;
using ::remquol;
using ::rint;
using ::rintf;
using ::rintl;
using ::round;
using ::roundf;
using ::roundl;
using ::scalbln;
using ::scalblnf;
using ::scalblnl;
using ::scalbn;
using ::scalbnf;
using ::scalbnl;
using ::tgamma;
using ::tgammaf;
using ::tgammal;
using ::trunc;
using ::truncf;
using ::truncl;
}
#endif
#endif

View File

@@ -11,7 +11,7 @@
#include <stdio.h>
#else
#include <stdio.h>
#endif // y66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666t`g71y6hhhhhh
#endif
namespace Poincare {
@@ -21,7 +21,7 @@ class LayoutNode;
class Integer;
struct IntegerDivision;
#ifdef _PRIZM
#if (defined _3DS) || (defined _PRIZM)
typedef unsigned short half_native_uint_t;
static_assert(sizeof(half_native_uint_t) == sizeof(uint16_t));
typedef int native_int_t;

View File

@@ -115,11 +115,9 @@ protected:
TreeHandle(const TreeNode * node);
// Un-inlining this constructor actually inscreases the firmware size
TreeHandle(uint16_t nodeIndentifier = TreeNode::NoNodeIdentifier) : m_identifier(nodeIndentifier) {
// debugLog22("Creating TreeHandle");
if (hasNode(nodeIndentifier)) {
node()->retain();
}
// debugLog22("Created TreeHandle");
}
// WARNING: if the children table is the result of a cast, the object downcasted has to be the same size as a TreeHandle.

View File

@@ -1,9 +1,3 @@
// Don't optimize this file
#include <ios>
// #pragma GCC push_options
// #pragma GCC optimize ("O0")
#include <cstdio>
#include <poincare/integer.h>
#include <poincare/code_point_layout.h>
#include <poincare/ieee754.h>
@@ -644,6 +638,12 @@ Integer Integer::multiplyByPowerOfBase(uint8_t pow) const {
IntegerDivision Integer::udiv(const Integer & numerator, const Integer & denominator) {
if (denominator.isOverflow()) {
return {.quotient = Overflow(false), .remainder = Integer::Overflow(false)};
}
if (numerator.isOverflow()) {
return {.quotient = Overflow(false), .remainder = Integer::Overflow(false)};
}
/* Modern Computer Arithmetic, Richard P. Brent and Paul Zimmermann
* (Algorithm 1.6) */
assert(!denominator.isZero());
@@ -711,7 +711,6 @@ IntegerDivision Integer::udiv(const Integer & numerator, const Integer & denomin
if (pow > 0 && !div.remainder.isZero()) {
div.remainder = div.remainder.divideByPowerOf2(pow);
}
// printf("%u / %u = %u\n", numerator.digit(0), denominator.digit(0), div.quotient.digit(0));
return div;
}
@@ -744,5 +743,3 @@ template float Integer::approximate<float>() const;
template double Integer::approximate<double>() const;
}
// #pragma GCC pop_options

View File

@@ -4,28 +4,6 @@
#include <algorithm>
#include <stdlib.h>
// #include <stdio.h>
// #ifdef _PRIZM
// #include <gint/display-cg.h>
// #include <gint/display.h>
// #include <gint/keyboard.h>
// #define debugLog(format, ...) { \
// char buffer[100]; \
// snprintf(buffer, 100, format, ##__VA_ARGS__); \
// dclear(C_WHITE); \
// dtext(1, 1, C_BLACK, buffer); \
// dupdate(); \
// getkey(); \
// }
// #else
// #define debugLog(format, ...) { \
// char buffer[100]; \
// snprintf(buffer, 100, format, ##__VA_ARGS__); \
// printf("%s\n", buffer); \
// }
// #endif
namespace Poincare {
constexpr const Expression::FunctionHelper * Parser::s_reservedFunctions[];
@@ -47,29 +25,17 @@ bool Parser::IsReservedName(const char * name, size_t nameLength) {
// Private
const Expression::FunctionHelper * const * Parser::GetReservedFunction(const char * name, size_t nameLength) {
// debugLog("GetReservedFunction %s", name);
// // Print the first 3 bytes of the name
// debugLog("bytes %02X %02X %02X", (unsigned char)name[0], (unsigned char)name[1], (unsigned char)name[2]);
// // Print the first 3 bytes of the square root function
// debugLog("sqrt bytes %02X %02X %02X", (unsigned char)s_reservedFunctions[61]->name()[0], (unsigned char)s_reservedFunctions[61]->name()[1], (unsigned char)s_reservedFunctions[61]->name()[2]);
// debugLog("nameLength %d", nameLength);
const Expression::FunctionHelper * const * reservedFunction = s_reservedFunctions;
// int count = 0;
while (reservedFunction < s_reservedFunctionsUpperBound) {
// debugLog("against %d bytes %02X %02X %02X", count, (unsigned char)(**reservedFunction).name()[0], (unsigned char)(**reservedFunction).name()[1], (unsigned char)(**reservedFunction).name()[2]);
int nameDifference = Token::CompareNonNullTerminatedName(name, nameLength, (**reservedFunction).name());
if (nameDifference == 0) {
// debugLog("GetReservedFunction %s found", (**reservedFunction).name());
return reservedFunction;
}
if (nameDifference < 0) {
break;
}
reservedFunction++;
// count++;
}
// debugLog("GetReservedFunction %s not found", name);
return nullptr;
}

View File

@@ -10,26 +10,6 @@
* - an Expression, specifically for a Number Token,
* - a string (m_text, m_length), specifically for an Identifier Token. */
inline int strcmp2(const char *s1, const char *s2)
{
while (*s1 != '\0' && *s2 != '\0' && *s1 == *s2) {
s1 += 1;
s2 += 1;
}
return ((int)(unsigned char) *s1 - (int)(unsigned char) *s2);
}
inline int strncmp2(const char *s1, const char *s2, size_t n)
{
if (n == 0)
return (0);
size_t i = -1;
while (++i < n - 1 && s1[i] != '\0' && s2[i] != '\0'
&& s1[i] == s2[i]) ;
return ((unsigned char) s1[i] - (unsigned char) s2[i]);
}
namespace Poincare {
class Token {
@@ -98,8 +78,8 @@ public:
/* Compare m_text to name, similarly to strcmp, assuming
* - m_text is not null-terminated
* - name is.*/
int diff = strncmp2(nonNullTerminatedName, nullTerminatedName, nonNullTerminatedNameLength);
return (diff != 0) ? diff : strcmp2("", nullTerminatedName + nonNullTerminatedNameLength);
int diff = strncmp(nonNullTerminatedName, nullTerminatedName, nonNullTerminatedNameLength);
return (diff != 0) ? diff : strcmp("", nullTerminatedName + nonNullTerminatedNameLength);
}
int compareTo(const char * name) const {

View File

@@ -3,28 +3,6 @@
#include <poincare/number.h>
#include <ion/unicode/utf8_decoder.h>
// #include <stdio.h>
// #ifdef _PRIZM
// #include <gint/display-cg.h>
// #include <gint/display.h>
// #include <gint/keyboard.h>
// #define debugLog(format, ...) { \
// char buffer[100]; \
// snprintf(buffer, 100, format, ##__VA_ARGS__); \
// dclear(C_WHITE); \
// dtext(1, 1, C_BLACK, buffer); \
// dupdate(); \
// getkey(); \
// }
// #else
// #define debugLog(format, ...) { \
// char buffer[100]; \
// snprintf(buffer, 100, format, ##__VA_ARGS__); \
// printf("%s\n", buffer); \
// }
// #endif
namespace Poincare {
const CodePoint Tokenizer::nextCodePoint(PopTest popTest, CodePoint context, bool * testResult) {

View File

@@ -9,28 +9,6 @@
#include "token.h"
// #include <stdio.h>
// #ifdef _PRIZM
// #include <gint/display-cg.h>
// #include <gint/display.h>
// #include <gint/keyboard.h>
// #define debugLog(format, ...) { \
// char buffer[100]; \
// snprintf(buffer, 100, format, ##__VA_ARGS__); \
// dclear(C_WHITE); \
// dtext(1, 1, C_BLACK, buffer); \
// dupdate(); \
// getkey(); \
// }
// #else
// #define debugLog(format, ...) { \
// char buffer[100]; \
// snprintf(buffer, 100, format, ##__VA_ARGS__); \
// printf("%s\n", buffer); \
// }
// #endif
namespace Poincare {
class Tokenizer {

View File

@@ -299,37 +299,6 @@ KDColor MicroPython::Color::Parse(mp_obj_t input, Mode mode){
mp_raise_TypeError("Color couldn't be parsed");
}
// typedef uintptr_t gc_helper_regs_t[8];
// STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
// register const long r8 asm ("r8");
// register const long r9 asm ("r9");
// register const long r10 asm ("r10");
// register const long r11 asm ("r11");
// register const long r12 asm ("r12");
// register const long r13 asm ("r13");
// register const long r14 asm ("r14");
// register const long r15 asm ("r15");
// arr[0] = r8;
// arr[1] = r9;
// arr[2] = r10;
// arr[3] = r11;
// arr[4] = r12;
// arr[5] = r13;
// arr[6] = r14;
// arr[7] = r15;
// }
// MP_NOINLINE void gc_helper_collect_regs_and_stack(void) {
// gc_helper_regs_t regs;
// gc_helper_get_regs(regs);
// // GC stack (and regs because we captured them)
// void **regs_ptr = (void **)(void *)&regs;
// gc_collect_root(regs_ptr, ((uintptr_t)MP_STATE_THREAD(stack_top) - (uintptr_t)&regs) / sizeof(uintptr_t));
// }
// #define gc_collect_regs_and_stack gc_helper_collect_regs_and_stack
void gc_collect_regs_and_stack(void) {
// get the registers and the sp
jmp_buf regs;