Remove unexistant referenced file #3

Closed
Ghost wants to merge 7 commits from (deleted):build-fix_prof-shaders into dev
23 changed files with 586 additions and 535 deletions

124
CMakeLists.txt Normal file
View File

@ -0,0 +1,124 @@
# gintctl: gint's control application
cmake_minimum_required(VERSION 3.18)
project(gintctl VERSION 2.2.1 LANGUAGES C ASM)
include(GenerateG1A)
include(GenerateG3A)
include(Fxconv)
find_package(Gint 2.1 REQUIRED)
find_package(LibProf 2.1 REQUIRED)
find_package(LibImg 2.1 REQUIRED)
set(SOURCES
src/gintctl.c
src/menu.c
src/plot.c
src/util.c
src/gint/bopti.c
src/gint/cpumem.c
src/gint/dma.c
src/gint/dsp.c
src/gint/dsp.s
src/gint/dump.c
src/gint/gray.c
src/gint/keyboard.c
src/gint/ram.c
src/gint/rtc.c
src/gint/spuram.c
src/gint/switch.c
src/gint/timer.c
src/gint/timer_callbacks.c
src/gint/tlb.c
src/gint/topti.c
src/libs/libimg.c
src/libs/memory.c
src/libs/openlibm.c
src/libs/printf.c
src/libs/tinymt.c
src/mem/mem.c
src/perf/cpucache.c
src/perf/cpucache.S
src/perf/interrupt.c
src/perf/libprof.c
src/perf/memory.c
src/perf/memory.s
src/perf/render.c
src/regs/regs.c
)
set(ASSETS_fx
assets-fx/fonts/hexa.png
assets-fx/fonts/uf5x7
assets-fx/img/bopti_1col.png
assets-fx/img/bopti_2col.png
assets-fx/img/bopti_3col.png
assets-fx/img/keypress.png
assets-fx/img/keyrelease.png
assets-fx/img/libimg_swords.png
assets-fx/img/opt_dump.png
assets-fx/img/opt_gint_bopti.png
assets-fx/img/opt_gint_cpumem.png
assets-fx/img/opt_gint_gray.png
assets-fx/img/opt_gint_ram.png
assets-fx/img/opt_gint_rtc.png
assets-fx/img/opt_gint_spuram.png
assets-fx/img/opt_gint_timer_callbacks.png
assets-fx/img/opt_gint_timers.png
assets-fx/img/opt_gint_tlb.png
assets-fx/img/opt_main.png
assets-fx/img/opt_mem.png
assets-fx/img/opt_perf_libprof.png
assets-fx/img/opt_perf_render.png
assets-fx/img/opt_switch_ctx.png
assets-fx/img/opt_switch_ctx_sh3.png
assets-fx/img/opt_switch.png
assets-fx/img/profile_gray_alpha.png
assets-fx/img/profile_gray.png
assets-fx/img/profile_mono_alpha.png
assets-fx/img/profile_mono.png
assets-fx/img/rtc_arrows.png
assets-fx/img/rtc_segments.png
assets-fx/img/tlb_cells.png
)
set(ASSETS_cg
assets-cg/fonts/font8x9_bold.png
assets-cg/img/applejack_31x27.png
assets-cg/img/applejack_36x25.png
assets-cg/img/kbd_pressed.png
assets-cg/img/kbd_released.png
assets-cg/img/libimg_even_odd.png
assets-cg/img/libimg_odd_even.png
assets-cg/img/libimg_sq_even.png
assets-cg/img/libimg_sq_odd.png
assets-cg/img/libimg_train.png
assets-cg/img/potion_17x22.png
assets-cg/img/potion_18x22.png
assets-cg/img/potion_21x22.png
assets-cg/img/rtc_arrows.png
assets-cg/img/rtc_segments.png
assets-cg/img/swift.png
assets-cg/img/swords.png
)
fxconv_declare_assets(${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(gintctl ${SOURCES} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(gintctl PRIVATE
-Wall -Wextra -Os)
target_link_options(gintctl PRIVATE
-Wl,-Map=map -Wl,--print-memory-usage)
target_include_directories(gintctl PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${FXSDK_COMPILER_INSTALL}/include/openlibm")
target_link_libraries(gintctl
Gint::Gint LibProf::LibProf LibImg::LibImg -lopenlibm)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(TARGET gintctl OUTPUT "gintctl.g1a"
NAME "gintctl" INTERNAL "@GINTCTL" ICON assets-fx/icon.png)
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET gintctl OUTPUT "gintctl.g3a"
NAME "" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

198
Makefile
View File

@ -1,198 +0,0 @@
#! /usr/bin/make -f
# Default Makefile for fxSDK add-ins. This file was probably copied there by
# the [fxsdk] program.
#---
#
# Configuration
#
include project.cfg
# Compiler flags
CFLAGSFX = $(CFLAGS) $(CFLAGS_FX) $(INCLUDE_FX)
CFLAGSCG = $(CFLAGS) $(CFLAGS_CG) $(INCLUDE_CG)
# Linker flags
LDFLAGSFX := $(LDFLAGS) $(LDFLAGS_FX)
LDFLAGSCG := $(LDFLAGS) $(LDFLAGS_CG)
# Dependency list generation flags
depflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
# ELF to binary flags
BINFLAGS := -R .bss -R .gint_bss
# G1A and G3A generation flags
NAME_G1A ?= $(NAME)
NAME_G3A ?= $(NAME)
G1AF := -i "$(ICON_FX)" -n "$(NAME_G1A)" --internal="$(INTERNAL)"
G3AF := -n basic:"$(NAME_G3A)" -i uns:"$(ICON_CG_UNS)" -i sel:"$(ICON_CG_SEL)"
ifeq "$(TOOLCHAIN_FX)" ""
TOOLCHAIN_FX := sh3eb-elf
endif
ifeq "$(TOOLCHAIN_CG)" ""
TOOLCHAIN_CG := sh4eb-elf
endif
# fxconv flags
FXCONVFX := --fx --toolchain=$(TOOLCHAIN_FX)
FXCONVCG := --cg --toolchain=$(TOOLCHAIN_CG)
# Determine the compiler install and include path
GCC_BASE_FX := $(shell $(TOOLCHAIN_FX)-gcc --print-search-dirs | grep install | sed 's/install: //')
GCC_BASE_CG := $(shell $(TOOLCHAIN_CG)-gcc --print-search-dirs | grep install | sed 's/install: //')
GCC_INCLUDE_FX := $(GCC_BASE_FX)/include
GCC_INCLUDE_CG := $(GCC_BASE_CG)/include
#
# File listings
#
NULL :=
TARGET := $(subst $(NULL) $(NULL),-,$(NAME))
ifeq "$(TARGET_FX)" ""
TARGET_FX := $(TARGET).g1a
endif
ifeq "$(TARGET_CG)" ""
TARGET_CG := $(TARGET).g3a
endif
ELF_FX := build-fx/$(shell basename -s .g1a $(TARGET_FX)).elf
BIN_FX := $(ELF_FX:.elf=.bin)
ELF_CG := build-cg/$(shell basename -s .g3a $(TARGET_CG)).elf
BIN_CG := $(ELF_CG:.elf=.bin)
# Source files
src := $(wildcard src/*.[csS] \
src/*/*.[csS] \
src/*/*/*.[csS] \
src/*/*/*/*.[csS])
assets-fx := $(wildcard assets-fx/*/*)
assets-cg := $(wildcard assets-cg/*/*)
# Object files
obj-fx := $(src:%=build-fx/%.o) \
$(assets-fx:assets-fx/%=build-fx/assets/%.o)
obj-cg := $(src:%=build-cg/%.o) \
$(assets-cg:assets-cg/%=build-cg/assets/%.o)
# Additional dependencies
deps-fx := $(ICON_FX)
deps-cg := $(ICON_CG_UNS) $(ICON_CG_SEL)
# All targets
all :=
ifneq "$(wildcard build-fx)" ""
all += all-fx
endif
ifneq "$(wildcard build-cg)" ""
all += all-cg
endif
#
# Build rules
#
all: $(all)
all-fx: $(TARGET_FX)
all-cg: $(TARGET_CG)
$(TARGET_FX): $(obj-fx) $(deps-fx)
@ mkdir -p $(dir $@)
$(TOOLCHAIN_FX)-gcc -o $(ELF_FX) $(obj-fx) $(CFLAGSFX) $(LDFLAGSFX)
$(TOOLCHAIN_FX)-objcopy -O binary $(BINFLAGS) $(ELF_FX) $(BIN_FX)
fxg1a $(BIN_FX) -o $@ $(G1AF)
$(TARGET_CG): $(obj-cg) $(deps-cg)
@ mkdir -p $(dir $@)
$(TOOLCHAIN_CG)-gcc -o $(ELF_CG) $(obj-cg) $(CFLAGSCG) $(LDFLAGSCG)
$(TOOLCHAIN_CG)-objcopy -O binary $(BINFLAGS) $(ELF_CG) $(BIN_CG)
mkg3a $(G3AF) $(BIN_CG) $@
# C sources
build-fx/%.c.o: %.c
@ mkdir -p $(dir $@)
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(CFLAGSFX) $(depflags)
build-cg/%.c.o: %.c
@ mkdir -p $(dir $@)
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(CFLAGSCG) $(depflags)
# Assembler sources
build-fx/%.s.o: %.s
@ mkdir -p $(dir $@)
$(TOOLCHAIN_FX)-gcc -c $< -o $@ -Wa,--dsp
build-cg/%.s.o: %.s
@ mkdir -p $(dir $@)
$(TOOLCHAIN_CG)-gcc -c $< -o $@ -Wa,--dsp
# Preprocessed assembler sources
build-fx/%.S.o: %.S
@ mkdir -p $(dir $@)
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(INCLUDE_FX) -Wa,--dsp
build-cg/%.S.o: %.S
@ mkdir -p $(dir $@)
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE_CG) -Wa,--dsp
# Images
build-fx/assets/img/%.o: assets-fx/img/%
@ mkdir -p $(dir $@)
fxconv --bopti-image $< -o $@ $(FXCONVFX) name:img_$(basename $*) $(IMG.$*)
build-cg/assets/img/%.o: assets-cg/img/%
@ mkdir -p $(dir $@)
fxconv --bopti-image $< -o $@ $(FXCONVCG) name:img_$(basename $*) $(IMG.$*)
# Fonts
build-fx/assets/fonts/%.o: assets-fx/fonts/%
@ mkdir -p $(dir $@)
fxconv -f $< -o $@ $(FXCONVFX) name:font_$(basename $*) $(FONT.$*)
build-cg/assets/fonts/%.o: assets-cg/fonts/%
@ mkdir -p $(dir $@)
fxconv -f $< -o $@ $(FXCONVCG) name:font_$(basename $*) $(FONT.$*)
# Binaries
build-fx/assets/bin/%.o: assets-fx/bin/%
@ mkdir -p $(dir $@)
fxconv -b $< -o $@ $(FXCONVFX) name:bin_$(basename $*) $(BIN.$*)
build-cg/assets/bin/%.o: assets-cg/bin/%
@ mkdir -p $(dir $@)
fxconv -b $< -o $@ $(FXCONVCG) name:bin_$(basename $*) $(BIN.$*)
#
# Cleaning and utilities
#
# Dependency information
-include $(shell find build* -name *.d 2> /dev/null)
build-fx/%.d: ;
build-cg/%.d: ;
.PRECIOUS: build-fx build-cg build-fx/%.d build-cg/%.d %/
clean-fx:
@ rm -rf build-fx/
clean-cg:
@ rm -rf build-cg/
distclean-fx: clean-fx
@ rm -f $(TARGET_FX)
distclean-cg: clean-cg
@ rm -f $(TARGET_CG)
clean: clean-fx clean-cg
distclean: distclean-fx distclean-cg
install-fx: $(TARGET_FX)
p7 send -f $<
install-cg: $(TARGET_CG)
@ prizm-mount
@ rm -f /mnt/prizm/$<
@ cp $< /mnt/prizm
@ prizm-eject
.PHONY: all all-fx all-cg clean distclean install-fx install-cg

View File

@ -0,0 +1,8 @@
font8x9_bold.png:
type: font
name: font_font8x9_bold
charset: print
grid.size: 8x11
grid.padding: 1
grid.border: 0
proportional: true

View File

@ -0,0 +1,15 @@
*:
type: bopti-image
name_regex: (.*).png img_\1
libimg_*.png:
type: libimg-image
swift.png:
profile: p4
swords.png:
profile: p8
kbd_pressed.png:
profile: p4
kbd_released.png:
profile: p4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,13 @@
hexa.png:
type: font
name: font_hexa
charset: print
grid.size: 3x5
grid.padding: 1
uf5x7:
type: font
name: font_uf5x7
charset: unicode
grid.size: 5x7
grid.padding: 1

View File

@ -0,0 +1,6 @@
*:
type: bopti-image
name_regex: (.*)\.png img_\1
libimg_swords.png:
type: libimg-image

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -5,8 +5,8 @@
#ifndef GINTCTL_GINT
#define GINTCTL_GINT
/* gintctl_gint_hardware(): Detected hardware configuration */
void gintctl_gint_hardware(void);
/* gintctl_gint_cpumem(): Detected CPU and memory configuration */
void gintctl_gint_cpumem(void);
/* gintctl_gint_ram(): Determine the size of some memory areas */
void gintctl_gint_ram(void);

View File

@ -12,6 +12,14 @@
struct menuentry {
char const *name;
void (*function)(void);
int flags;
};
enum {
/* SH3-only */
MENU_SH3_ONLY,
/* SH4-only */
MENU_SH4_ONLY,
};
struct menu {
@ -27,6 +35,9 @@ struct menu {
};
/* menu_init(): Initialize a menu list
This function will initialize the menu data and remove entries that are not
available on the current platform?
@menu Any list menu, even uninitialized
@top Number of lines reserved on top (including title on fx9860g)
@bottom Number of lines reserved at bottom */

View File

@ -1,103 +0,0 @@
#---
# fxSDK project configuration file for gintctl
#---
# Project name, should be at most 8 bytes long.
# (You can also specify NAME_G1A or NAME_G3A to override individually.)
NAME := gintctl
NAME_G3A :=
# Internal name, should be '@' followed by at most 7 uppercase letters.
# WARNING: If this convention is not followed, the add-in might not appear in
# the main menu of the calculator!
INTERNAL := @GINTCTL
# Output file name. The default is to take <NAME>, replace spaces with dashes,
# and add .g1a (or .g3a). You can specify a different folder if you want.
TARGET_FX :=
TARGET_CG :=
# fx-9860G icon location
ICON_FX = assets-fx/icon.png
# fx-CG 50 icon locations
ICON_CG_UNS = assets-cg/icon-uns.png
ICON_CG_SEL = assets-cg/icon-sel.png
#---
# Toolchain selection
#---
# Toolchain for fx9860g. Please see also CFLAGS_FX below.
TOOLCHAIN_FX := sh-elf
# Toolchain for fxcg50. Please see also CFLAGS_CG below.
TOOLCHAIN_CG := sh-elf
#---
# Compiler flags
#---
# Base compiler flags for the fxSDK, you usually want to keep these.
CFLAGS := -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields
# Platform-specific compiler flags.
# <> If you are using sh3eb-elf, use -m3. (You can do this on both FX and CG.)
# <> If you are using sh4eb-elf, use -m4-nofpu. (Not ideal on FX but works.)
# <> If you are using sh4eb-nofpu-elf, then your compiler will likely use the
# FPU and cause problems on the calculator. Consider another configuration.
# <> If you are using an sh-elf with several targets, specify whichever you
# support. I recommend -m3 on FX and -m4-nofpu on CG.
# Please see also TOOLCHAIN_FX and TOOLCHAIN_CG above.
CFLAGS_FX := -D FX9860G -m3
CFLAGS_CG := -D FXCG50 -m4-nofpu
# Additional compiler flags, change to your own taste!
CFLAGS += -Wall -Wextra -Os
# Include paths. Add one -I option for each folder from which you want to
# be able to include files with #include<>. The Makefile provides a variable
# GCC_INCLUDE_FX/GCC_INCLUDE_CG that represents the default include folder,
# which is useful for some libraries such as OpenLibm.
INCLUDE_FX = -I include -I $(GCC_INCLUDE_FX)/openlibm
INCLUDE_CG = -I include -I $(GCC_INCLUDE_CG)/openlibm
# Libraries. Add one -l option for each library you are using, and also
# suitable -L options if you have library files in custom folders. To use
# fxlib, add libfx.a to the project directory and use "-L . -lfx".
LIBS_FX := -lprof -limg-fx -lopenlibm
LIBS_CG := -lprof -limg-cg -lopenlibm
# Base linker flags for the fxSDK, you usually want to keep these.
LDFLAGS_FX := -T fx9860g.ld -lgint-fx $(LIBS_FX) -lgint-fx -lgcc
LDFLAGS_CG := -T fxcg50.ld -lgint-cg $(LIBS_CG) -lgint-cg -lgcc
# Additional linker flags, if you need any.
LDFLAGS := -Wl,--print-memory-usage
# Additional platform-specific linker flags.
LDFLAGS_FX += -Wl,-Map=build-fx/map
LDFLAGS_CG += -Wl,-Map=build-cg/map
#---
# File conversion parameters
#---
# Parameters for the hexadecimal font on fx9860g
FONT.hexa.png = charset:print grid.size:3x5 grid.padding:1
FONT.font8x9_bold.png = charset:print grid.size:8x11 grid.padding:1 \
grid.border:0 proportional:true
FONT.uf5x7 = charset:unicode grid.size:5x7 grid.padding:1
IMG.swift.png = profile:p4
IMG.swords.png = profile:p8
IMG.kbd_pressed.png = profile:p4
IMG.kbd_released.png = profile:p4
IMG.libimg_even_odd.png = type:libimg-image
IMG.libimg_odd_even.png = type:libimg-image
IMG.libimg_sq_even.png = type:libimg-image
IMG.libimg_sq_odd.png = type:libimg-image
IMG.libimg_train.png = type:libimg-image
IMG.libimg_swords.png = type:libimg-image

View File

@ -1,6 +1,7 @@
#include <gint/hardware.h>
#include <gint/keyboard.h>
#include <gint/display.h>
#include <gint/mmu.h>
#include <gintctl/gint.h>
#include <gintctl/util.h>
@ -34,8 +35,8 @@ void show_mpucpu(void)
};
char const *calc_names[] = {
"Unknown",
"SH-3 fx-9860G-like",
"SH-4 fx-9860G-like",
"SH3 fx-9860G*",
"SH4 fx-9860G*",
"Graph 35+E II",
"Prizm fx-CG 20",
"fx-CG 50/Graph 90+E",
@ -45,82 +46,75 @@ void show_mpucpu(void)
int mpu = gint[HWMPU];
int calc = gint[HWCALC];
char const *str_calc = _("Model", "Calculator model");
if(calc < 0 || calc > 6)
row_print(1, 1, "Calculator model: <CALCID %d>", calc);
row_print(1, 1, "%s: <CALCID %d>", str_calc, calc);
else
row_print(1, 1, "Calculator model: %s", calc_names[calc]);
row_print(1, 1, "%s: %s", str_calc, calc_names[calc]);
if(mpu < 0 || mpu > 4)
row_print(3, 1, "MPU: <MPUID %d>", mpu);
row_print(_(2,3), 1, "MPU: <MPUID %d>", mpu);
else
row_print(3, 1, "MPU: %s", mpu_names[mpu]);
if(!isSH4()) return;
row_print(4, 1, _(" PVR:"," Processor Version Register: ") "%08x",
gint[HWCPUVR]);
row_print(5, 1, _(" PRR:"," Product Register: ") "%08x",gint[HWCPUPR]);
row_print(_(2,3), 1, "MPU: %s", mpu_names[mpu]);
volatile uint32_t *CPUOPM = (void *)0xff2f0000;
row_print(6, 1, _(" CPUOPM:"," CPU Operation Mode: ") "%08x", *CPUOPM);
uint32_t SR;
__asm__("stc sr, %0" : "=r"(SR));
row_print(7, 1, _(" SR:", " Status Register: ") "%08x", SR);
#ifdef FX9860G
if(isSH3())
{
row_print(4, 1, " SR %08x", SR);
return;
}
row_print(4, 1, " SR %08x", SR);
row_print(5, 1, " PVR %08x", gint[HWCPUVR]);
row_print(6, 1, " PRR %08x", gint[HWCPUPR]);
row_print(7, 1, " CPUOPM %08x", *CPUOPM);
#endif
#ifdef FXCG50
row_print(4, 1, " Status Register: %08x", SR);
row_print(5, 1, " Processor Version Register: %08x", gint[HWCPUVR]);
row_print(6, 1, " Product Register: %08x", gint[HWCPUPR]);
row_print(7, 1, " CPU Operation Mode: %08x", *CPUOPM);
#endif
}
/* Memory */
static void show_memory(void)
{
uint32_t base_rom = 0x80000000;
uint32_t base_ram = 0x88000000;
uint32_t base_uram = (uint32_t)mmu_uram();
int rom = gint[HWROM];
int ram = gint[HWRAM];
int uram = gint[HWURAM];
#ifdef FX9860G
row_print(1, 1, "ROM: %dM", rom >> 20);
row_print(2, 1, "RAM:%dk (%dk user)", ram >> 10, uram >> 10);
row_title("Basic memory layout");
row_print(3, 2, "%08x %4dk ROM", base_rom, rom >> 10);
row_print(4, 2, "%08x %4dk RAM", base_ram, ram >> 10);
row_print(5, 2, "%08x %4dk URAM", base_uram, uram >> 10);
#endif
#ifdef FXCG50
if(gint[HWCALC] == HWCALC_FXCG50) base_ram = 0x8c000000;
row_print(1, 1, "ROM: %dM", rom >> 20);
row_print(2, 2, "%08X .. %08X", 0x80000000, 0x80000000+rom-1);
row_print(3, 1, "RAM: %dM (%dk mapped in userspace)",
ram >> 20, uram >> 10);
row_print(2, 2, "%08X ... %08X", 0x80000000, 0x80000000+rom-1);
row_print(3, 1, "RAM: %dM", ram >> 20);
row_print(4, 2, "%08X ... %08X", base_ram, base_ram+ram-1);
row_print(5, 1, "Userspace RAM: %dk mapped", uram >> 10);
row_print(6, 2, "%08X ... %08X", base_uram, base_uram+uram-1);
#endif
}
/* Extra Timer Unit */
static void hw_etmu(int *row)
{
int etmu = gint[HWETMU];
put("Extra Timer Unit" _(,":"));
load_barrier(etmu);
if(etmu & HWETMU_1)
{
put(" Extra timers: 1");
put(" Operational: %c", (etmu & HWETMU_OK0 ? 'y' : 'n'));
}
else if(etmu & HWETMU_6)
{
char operational[7] = { 0 };
for(int i = 0; i < 6; i++)
operational[i] = etmu & (1 << (i + 2)) ? 'y' : 'n';
put(" Extra timers: 6");
put(" Operational: %s", operational);
}
}
/* Keyboard */
#if 0
static void hw_keyboard(int *row)
{
int kbd = gint[HWKBD];
put("Keyboard" _(,":"), kbd);
load_barrier(kbd);
if(kbd & HWKBD_IO)
{
put(_(" I/O driven","Driven by I/O port scanning"));
@ -134,17 +128,13 @@ static void hw_keyboard(int *row)
" Driven by SH7305-style key scan interface"));
}
put(_(" Scans at %dHz"," Scans keys at %dHz"), gint[HWKBDSF]);
// + scan frequency
}
/* Display driver */
static void hw_display(int *row)
{
int dd = gint[HWDD];
put("Display" _(,":"));
load_barrier(dd);
#ifdef FXCG50
if(dd & HWDD_KNOWN) put(" Known R61524-type model");
if(dd & HWDD_FULL) put(" Fullscreen mode enabled (no borders)");
@ -157,28 +147,12 @@ static void hw_display(int *row)
if(dd & HWDD_LIGHT) put(_(" Backlight supported",
" Backlight configuration is enabled"));
}
#endif
static int display_data(int offset)
/* gintctl_gint_cpumem(): Detected CPU and memory configuration */
void gintctl_gint_cpumem(void)
{
int row_value = -offset;
int *row = &row_value;
hw_etmu(row);
put("");
hw_keyboard(row);
put("");
hw_display(row);
return row_value + offset;
}
/* gintctl_hardware(): Show the hardware screen */
void gintctl_gint_hardware(void)
{
int offset = 0, tab = 0;
int max, key = 0;
int tab=0, key=0;
while(key != KEY_EXIT)
{
@ -186,30 +160,21 @@ void gintctl_gint_hardware(void)
if(tab == 0) show_mpucpu();
if(tab == 1) show_memory();
if(tab == 2)
{
max = display_data(offset);
scrollbar(offset, max, 1, row_count() + 1);
}
#ifdef FX9860G
extern bopti_image_t img_opt_gint_cpumem;
dimage(0, 56, &img_opt_gint_cpumem);
#endif
#ifdef FXCG50
row_title("Hardware and loaded drivers");
row_title("Processor and memory");
fkey_menu(1, "MPU/CPU");
fkey_menu(2, "MEMORY");
fkey_menu(3, "Other");
#endif
dupdate();
key = getkey().key;
if(key == KEY_F1) tab = 0;
if(key == KEY_F2) tab = 1;
if(key == KEY_F3) tab = 2;
if(tab == 2 && key == KEY_UP && offset > 0)
offset--;
if(tab == 2 && key == KEY_DOWN && max - offset > row_count())
offset++;
}
}

View File

@ -5,6 +5,8 @@
#include <gintctl/util.h>
#include <gintctl/gint.h>
#include <stdbool.h>
/* Byte-based memory detection functions */
static int writable(uint8_t volatile *mem)
@ -76,48 +78,60 @@ static int same_location_lword(uint8_t volatile *m1_8, uint8_t volatile *m2_8)
/* Region size detection */
static uint32_t region_size(uint8_t volatile *mem, int *reason, int use_lword)
struct region {
/* Region name (for display) [input] */
char const *name;
/* Region address [input] */
uint32_t mem;
/* Whether region supports only 32-bit access [input] */
bool use_lword;
/* Size of region [output] */
uint32_t size;
/* Reason why region is not larger [output] */
int reason;
};
static void explore_region(struct region *r)
{
uint32_t size = 0;
uint8_t volatile *mem = (void *)r->mem;
r->size = 0;
while(size < (1 << 20))
while(r->size < (1 << 20))
{
int x = use_lword
? writable_lword(mem + size)
: writable(mem + size);
int x = r->use_lword
? writable_lword(mem + r->size)
: writable(mem + r->size);
*reason = 1;
if(!x) return size;
r->reason = 1;
if(!x) return;
if(size > 0)
if(r->size > 0)
{
int y = use_lword
? same_location_lword(mem, mem+size)
: same_location(mem, mem+size);
*reason = 2;
if(y) return size;
int y = r->use_lword
? same_location_lword(mem, mem+r->size)
: same_location(mem, mem+r->size);
r->reason = 2;
if(y) return;
}
/* In PXYRAM, skip some longwords to go faster */
size += use_lword ? 32 : 1;
r->size += r->use_lword ? 32 : 4;
}
*reason = 3;
return size;
r->reason = 3;
}
#ifdef FX9860G
static void show_region(int row, char const *name, void *area, uint32_t size,
int reason)
static void show_region(int row, struct region *r)
{
/* Out-of-bounds rows */
if(row < 1 || row > 9 || (row == 1 && name)) return;
if(row < 1 || row > 9 || (row == 1 && r)) return;
extern font_t font_hexa;
font_t const *old_font = dfont(&font_hexa);
int y = (row - 1) * 6;
if(!name)
if(!r)
{
dprint( 1, y, C_BLACK, "Area");
dprint(24, y, C_BLACK, "Address");
@ -129,48 +143,69 @@ static void show_region(int row, char const *name, void *area, uint32_t size,
char const *reasons[] = { "", "Read-only", "Loops", "" };
dprint( 1, y, C_BLACK, "%s", name);
dprint(24, y, C_BLACK, "%08X", (uint32_t)area);
dprint( 1, y, C_BLACK, "%s", r->name);
dprint(24, y, C_BLACK, "%08X", r->mem);
if(reason != 0)
if(r->reason != 0)
{
dprint(60, y, C_BLACK, "%dk", size >> 10);
dprint(80, y, C_BLACK, "%s", reasons[reason]);
dprint(60, y, C_BLACK, "%dk", r->size >> 10);
dprint(80, y, C_BLACK, "%s", reasons[r->reason]);
}
dfont(old_font);
}
#endif
#ifdef FXCG50
static void show_region(int y, struct region *r)
{
char const *reasons[] = {
"Not tested",
"Not writable",
"Wraps around",
"Maybe larger!",
};
if(!r)
{
row_print(y, 2, "Area");
row_print(y, 9, "Address");
row_print(y, 18, "AS");
row_print(y, 22, "Size");
row_print(y, 35, "Reason");
return;
}
row_print(y, 2, "%s", r->name);
row_print(y, 9, "%08X", r->mem);
row_print(y, 18, "%d", r->use_lword ? 32 : 8);
row_print(y, 22, "%d bytes", r->size);
row_print(y, 35, reasons[r->reason]);
}
#endif
/* gintctl_gint_ram(): Determine the size of some memory areas */
void gintctl_gint_ram(void)
{
uint8_t *ILRAM = (void *)0xe5200000;
uint8_t *XRAM = (void *)0xe5007000;
uint8_t *YRAM = (void *)0xe5017000;
uint8_t *PRAM0 = (void *)0xfe200000;
uint8_t *XRAM0 = (void *)0xfe240000;
uint8_t *YRAM0 = (void *)0xfe280000;
uint8_t *PRAM1 = (void *)0xfe300000;
uint8_t *XRAM1 = (void *)0xfe340000;
uint8_t *YRAM1 = (void *)0xfe380000;
struct region r[] = {
{ "ILRAM", 0xe5200000, false, 0, 0 },
{ "XRAM", 0xe5007000, false, 0, 0 },
{ "YRAM", 0xe5017000, false, 0, 0 },
{ "PRAM0", 0xfe200000, true, 0, 0 },
{ "XRAM0", 0xfe240000, true, 0, 0 },
{ "YRAM0", 0xfe280000, true, 0, 0 },
{ "PRAM1", 0xfe300000, true, 0, 0 },
{ "XRAM1", 0xfe340000, true, 0, 0 },
{ "YRAM1", 0xfe380000, true, 0, 0 },
{ "X_P2", 0xa5007000, false, 0, 0 },
{ "URAM", 0xa55f0000, false, 0, 0 },
{ NULL },
};
/* Size of these sections */
uint32_t IL=0, X=0, Y=0, P0=0, X0=0, Y0=0, P1=0, X1=0, Y1=0;
/* Reason why the region stops (1=not writable, 2=wraps around) */
int ILr=0, Xr=0, Yr=0, P0r=0, X0r=0, Y0r=0, P1r=0, X1r=0,Y1r=0;
/* Region count (for the scrolling list on fx-9860G */
/* Region count (for the scrolling list on fx-9860G) */
GUNUSED int region_count = 9;
/* List scroll no fx-9860G */
GUNUSED int scroll = 0;
GUNUSED char const *reasons[] = {
"Not tested yet",
"%d bytes (not writable)",
"%d bytes (wraps around)",
"%d bytes",
};
GUNUSED int scroll = spu_zero();
int key = 0;
while(key != KEY_EXIT)
@ -178,16 +213,11 @@ void gintctl_gint_ram(void)
dclear(C_WHITE);
#ifdef FX9860G
show_region( 1, NULL, NULL, 0, 0);
show_region( 2-scroll, "ILRAM", ILRAM, IL, ILr);
show_region( 3-scroll, "XRAM", XRAM, X, Xr);
show_region( 4-scroll, "YRAM", YRAM, Y, Yr);
show_region( 5-scroll, "PRAM0", PRAM0, P0, P0r);
show_region( 6-scroll, "XRAM0", XRAM0, X0, X0r);
show_region( 7-scroll, "YRAM0", YRAM0, Y0, Y0r);
show_region( 8-scroll, "PRAM1", PRAM1, P1, P1r);
show_region( 9-scroll, "XRAM1", XRAM1, X1, X1r);
show_region(10-scroll, "YRAM1", YRAM1, Y1, Y1r);
show_region(1, NULL);
for(int i = 0; i < region_count; i++)
{
show_region(i+2-scroll, &r[i]);
}
if(scroll > 0) triangle_up(7);
if(scroll < region_count - 8) triangle_down(49);
@ -198,40 +228,11 @@ void gintctl_gint_ram(void)
#ifdef FXCG50
row_title("On-chip memory discovery");
row_print(1, 1, "This program measures the size of on-chip");
row_print(2, 1, "memory sections by checking how far it can "
"write.");
row_print(4, 2, "ILRAM:");
row_print(5, 2, "XRAM:");
row_print(6, 2, "YRAM:");
row_print(7, 2, "PRAM0:");
row_print(8, 2, "XRAM0:");
row_print(9, 2, "YRAM0:");
row_print(10,2, "PRAM1:");
row_print(11,2, "XRAM1:");
row_print(12,2, "YRAM1:");
row_print(4, 10, "E5200000");
row_print(5, 10, "E5007000");
row_print(6, 10, "E5017000");
row_print(7, 10, "FE200000");
row_print(8, 10, "FE240000");
row_print(9, 10, "FE280000");
row_print(10,10, "FE300000");
row_print(11,10, "FE340000");
row_print(12,10, "FE380000");
row_print(4, 21, reasons[ILr], IL);
row_print(5, 21, reasons[Xr], X);
row_print(6, 21, reasons[Yr], Y);
row_print(7, 21, reasons[P0r], P0);
row_print(8, 21, reasons[X0r], X0);
row_print(9, 21, reasons[Y0r], Y0);
row_print(10,21, reasons[P1r], P1);
row_print(11,21, reasons[X1r], X1);
row_print(12,21, reasons[Y1r], Y1);
show_region(1, NULL);
for(int i = 0; r[i].name; i++)
{
show_region(i+2, &r[i]);
}
fkey_button(1, "ILRAM");
fkey_button(2, "XYRAM");
@ -244,24 +245,29 @@ void gintctl_gint_ram(void)
key = getkey().key;
if(key == KEY_F1)
{
IL = region_size(ILRAM, &ILr, 0);
explore_region(&r[0]);
}
if(key == KEY_F2)
{
X = region_size(XRAM, &Xr, 0);
Y = region_size(YRAM, &Yr, 0);
explore_region(&r[1]);
explore_region(&r[2]);
}
if(key == KEY_F3)
{
P0 = region_size(PRAM0, &P0r, 1);
X0 = region_size(XRAM0, &X0r, 1);
Y0 = region_size(YRAM0, &Y0r, 1);
explore_region(&r[3]);
explore_region(&r[4]);
explore_region(&r[5]);
}
if(key == KEY_F4)
{
P1 = region_size(PRAM1, &P1r, 1);
X1 = region_size(XRAM1, &X1r, 1);
Y1 = region_size(YRAM1, &Y1r, 1);
explore_region(&r[6]);
explore_region(&r[7]);
explore_region(&r[8]);
}
if(key == KEY_F5)
{
explore_region(&r[9]);
explore_region(&r[10]);
}
#ifdef FX9860G

View File

@ -40,6 +40,54 @@ static void restore(volatile uint32_t *area, uint32_t *save, int pages)
}
}
#ifdef FX9860G
static void render_header(int y, int bank_count)
{
y = 9 + 6*y;
dtext( 1, 9, C_BLACK, "Area");
dtext(24, 9, C_BLACK, "Address");
dtext(60, 9, C_BLACK, "Visible pages");
}
static void render_area(int y, char const *name, uint32_t *area)
{
y = 9 + 6*y;
dprint( 1, y, C_BLACK, "%s", name);
dprint(24, y, C_BLACK, "%08X", (uint32_t)area);
int b = 0, bank = 0;
while(1)
{
bank = bank_number(area);
if(b == 7) break;
dprint(60+8*b, y, C_BLACK, bank >= 0 ? "%d" : "-", bank);
area += 0x2000;
b++;
}
}
static void render_bank(int y, char const *name, volatile uint32_t *bank,
int banks, int dsp, int focus)
{
y = 9 + 6*y;
dprint( 1, y, C_BLACK, "%s", name);
dprint(29, y, C_BLACK, "=%02X", *bank);
for(int b = 0; b < banks; b++)
{
int active = *bank & (1 << b);
int x = 50 + 8*b - 1;
int ry = y + (dsp==0) - 1;
int fill = active ? C_BLACK : C_WHITE;
int border = (focus == b) ? C_BLACK : C_WHITE;
drect_border(x, ry, x+7, ry+5, fill, 1, border);
}
}
#endif
#ifdef FXCG50
static void render_header(int y, int bank_count)
{
@ -118,10 +166,47 @@ void gintctl_gint_spuram(void)
int cur_bank = 0;
int cur_page = 0;
#ifdef FX9860G
int tab = 0;
#endif
while(key != KEY_EXIT)
{
dclear(C_WHITE);
#ifdef FX9860G
row_title("SPU memory banking");
extern font_t font_hexa;
font_t *old_font = dfont(&font_hexa);
if(tab == 0)
{
render_header(0, 7);
render_area(1, "PRAM0", PRAM0);
render_area(2, "XRAM0", XRAM0);
render_area(3, "YRAM0", YRAM0);
render_area(4, "PRAM1", PRAM1);
render_area(5, "XRAM1", XRAM1);
render_area(6, "YRAM1", YRAM1);
}
else if(tab == 1)
{
render_bank(1, "PBANKC0", &SPU.PBANKC0, 5, 0,
(cur_bank == 0) ? cur_page : -1);
render_bank(2, "PBANKC1", &SPU.PBANKC1, 5, 1,
(cur_bank == 0) ? cur_page : -1);
render_bank(4, "XBANKC0", &SPU.XBANKC0, 7, 0,
(cur_bank == 1) ? cur_page : -1);
render_bank(5, "XBANKC1", &SPU.XBANKC1, 7, 1,
(cur_bank == 1) ? cur_page : -1);
}
dfont(old_font);
extern bopti_image_t img_opt_gint_spuram;
dimage(0, 56, &img_opt_gint_spuram);
#endif
#ifdef FXCG50
row_title("SPU memory: PRAM0, XRAM0, YRAM0, YRAM");
row_print(1, 1, "Pages layout in memory (offsets in kiB):");
@ -159,16 +244,21 @@ void gintctl_gint_spuram(void)
if(key == KEY_DOWN && cur_bank == 0)
cur_bank++;
if(key == KEY_F1 && cur_bank == 0)
if(key == KEY_F1 && cur_bank == 0 && _(tab == 1, 1))
{
SPU.PBANKC0 ^= (1 << cur_page);
SPU.PBANKC1 ^= (1 << cur_page);
}
if(key == KEY_F1 && cur_bank == 1)
if(key == KEY_F1 && cur_bank == 1 && _(tab == 1, 1))
{
SPU.XBANKC0 ^= (1 << cur_page);
SPU.XBANKC1 ^= (1 << cur_page);
}
#ifdef FX9860G
if(key == KEY_F2) tab = 0;
if(key == KEY_F3) tab = 1;
#endif
}
/* Restore the values we saved before altering page data */

View File

@ -4,6 +4,7 @@
#include <gint/keyboard.h>
#include <gint/gint.h>
#include <gint/hardware.h>
#include <gint/kprint.h>
#include <gintctl/util.h>
#include <gintctl/menu.h>
@ -33,46 +34,46 @@
struct menu menu_gint = {
_("gint tests", "gint features and driver tests"), .entries = {
{ "Hardware", gintctl_gint_hardware },
{ "RAM discovery", gintctl_gint_ram },
{ "CPU and memory", gintctl_gint_cpumem, 0 },
{ "RAM discovery", gintctl_gint_ram, MENU_SH4_ONLY },
#ifdef FXCG50
{ "DSP processors", gintctl_gint_dsp },
{ "SPU memory", gintctl_gint_spuram },
{ "DSP processors", gintctl_gint_dsp, 0 },
#endif
{ "Memory dump", gintctl_gint_dump },
{ "Switching to OS", gintctl_gint_switch },
{ "TLB management", gintctl_gint_tlb },
{ "Keyboard", gintctl_gint_keyboard },
{ "Timers", gintctl_gint_timer },
{ "Timer callbacks", gintctl_gint_timer_callbacks },
{ "SPU memory", gintctl_gint_spuram, MENU_SH4_ONLY },
{ "Memory dump", gintctl_gint_dump, 0 },
{ "Switching to OS", gintctl_gint_switch, 0 },
{ "TLB management", gintctl_gint_tlb, 0 },
{ "Keyboard", gintctl_gint_keyboard, 0 },
{ "Timers", gintctl_gint_timer, 0 },
{ "Timer callbacks", gintctl_gint_timer_callbacks, 0 },
#ifdef FXCG50
{ "DMA control", gintctl_gint_dma },
{ "DMA control", gintctl_gint_dma, 0 },
#endif
{ "Real-time clock", gintctl_gint_rtc },
{ "Image rendering", gintctl_gint_bopti },
{ "Text rendering", gintctl_gint_topti },
{ "Real-time clock", gintctl_gint_rtc, 0 },
{ "Image rendering", gintctl_gint_bopti, 0 },
{ "Text rendering", gintctl_gint_topti, 0 },
#ifdef FX9860G
{ "Gray engine", gintctl_gint_gray },
{ "Gray rendering", gintctl_gint_grayrender },
{ "Gray engine", gintctl_gint_gray, 0 },
{ "Gray rendering", gintctl_gint_grayrender, 0 },
#endif
{ NULL, NULL },
{ NULL, NULL, 0 },
}};
/* Performance menu */
struct menu menu_perf = {
_("Performance", "Performance benchmarks"), .entries = {
{ "libprof basics", gintctl_perf_libprof },
{ "CPU and cache", gintctl_perf_cpucache },
{ "Interrupt stress", gintctl_perf_interrupts },
{ "libprof basics", gintctl_perf_libprof, 0 },
{ "CPU and cache", gintctl_perf_cpucache, 0 },
{ "Interrupt stress", gintctl_perf_interrupts, 0 },
#ifdef FXCG50
{ "Memory access speed", gintctl_perf_memory },
{ "Memory access speed", gintctl_perf_memory, 0 },
#endif
{ "Rendering functions", gintctl_perf_render },
{ "Rendering functions", gintctl_perf_render, 0 },
/* TODO: Comparison with MonochromeLib */
{ NULL, NULL },
{ NULL, NULL, 0 },
}};
/* External libraries */
@ -80,16 +81,16 @@ struct menu menu_libs = {
_("Libraries", "External and standard libraries"), .entries = {
{ "libc: " _("TinyMT32", "TinyMT random number generation"),
gintctl_libs_tinymt },
{ "libc: " _("printf family", "Formatted printing functions"),
gintctl_libs_printf },
gintctl_libs_tinymt, 0 },
{ "libc: " _("printf family", "Formatted printing (with Grisu2b)"),
gintctl_libs_printf, 0 },
{ "libc: " _("mem functions", "Core memory functions"),
gintctl_libs_memory },
gintctl_libs_memory, 0 },
{ "libm: " _("OpenLibm", "OpenLibm floating-point functions"),
gintctl_libs_openlibm },
gintctl_libs_openlibm, 0 },
{ "libimg" _("",": Image transforms"),
gintctl_libs_libimg },
{ NULL, NULL },
gintctl_libs_libimg, 0 },
{ NULL, NULL, 0 },
}};
//---
@ -100,7 +101,7 @@ struct menu menu_libs = {
void gintctl_main(void)
{
#ifdef FX9860G
row_title("gint @%07x", GINT_HASH);
row_title("gint %s %07x", GINT_VERSION, GINT_HASH);
row_print(3, 1, "F2:gint tests");
row_print(4, 1, "F3:Performance");
@ -160,6 +161,9 @@ int main(GUNUSED int isappli, GUNUSED int optnum)
/* Start the profiling library */
prof_init();
/* Enable floating-point formatters */
kprint_enable_fp();
#ifdef FX9860G
/* Use the Unicode font uf5x7 on fx-9860G */
extern font_t font_uf5x7;

View File

@ -9,19 +9,25 @@
#include <gintctl/gint.h>
#include <gintctl/util.h>
#define NAN __builtin_nan("")
#define INFINITY __builtin_inf()
#define SCROLL_HEIGHT _(8,12)
struct printf_test {
char const *format;
/* Type, argument, string, answer, passed are set by macros below */
enum { TYPE_I32, TYPE_U32, TYPE_STR, TYPE_PTR, TYPE_U64 } type;
/* Argument information is set by macros below */
enum {
TYPE_I32, TYPE_U32, TYPE_STR, TYPE_PTR, TYPE_U64, TYPE_DBL
} type;
union {
int i32;
uint32_t u32;
char const *str;
void *ptr;
uint64_t u64;
double dbl;
};
char const *argument_as_string;
char const *solution;
@ -32,6 +38,7 @@ struct printf_test {
#define STR(s) TYPE_STR, { .str = s }, #s
#define PTR(p) TYPE_PTR, { .ptr = (void *)p }, #p
#define U64(u) TYPE_U64, { .u64 = u }, #u
#define DBL(d) TYPE_DBL, { .dbl = d }, #d
static struct printf_test const tests[] = {
/* Base cases with length and precision */
@ -40,11 +47,14 @@ static struct printf_test const tests[] = {
{ "%3d", I32(65536), "65536" },
{ "%6.4d", I32(17), " 0017" },
{ "%6.3d", I32(-1876), " -1876" },
{ "%.0d", I32(0), "" },
{ "%.d", I32(0), "" },
/* Sign */
{ "%+i", I32(15), "+15" },
{ "% 7i", I32(78372), " 78372" },
{ "% d", I32(65536), " 65536" },
/* Alignment */
{ "%08d", I32(-839), "-0000839" },
{ "%-6.4d", I32(17), "0017 " },
{ "%-+6.4i", I32(17), "+0017 " },
/* Bases */
@ -66,6 +76,86 @@ static struct printf_test const tests[] = {
{ "%-8.5s", STR("Hello, World!"), "Hello " },
{ "%c", I32(100), "d" },
{ "%6c", I32('#'), " #", },
/* Floating-point special values */
{ "%f", DBL(NAN), "nan" },
{ "%3.5F", DBL(NAN), "NAN" },
{ "%+2F", DBL(-INFINITY), "-INF" },
{ "%10G", DBL(INFINITY), "INF" },
{ "%+g", DBL(INFINITY), "inf" },
{ "%7.3e", DBL(-INFINITY), "-inf" },
{ "%8E", DBL(NAN), "NAN" },
/* Simple floating-point cases */
{ "%f", DBL(13e3), "13000.000000" },
{ "%.3f", DBL(-13e3), "-13000.000" },
{ "%.F", DBL(13e3), "13000" },
{ "%f", DBL(-12.42), "-12.420000" },
{ "%.0f", DBL(-12.42), "-12", },
{ "%.1f", DBL(12.42), "12.4", },
{ "%.8F", DBL(12.42), "12.42000000" },
{ "%F", DBL(0.0312), "0.031200" },
{ "%.4f", DBL(0.0312), "0.0312" },
{ "%.2f", DBL(-0.0312), "-0.03", },
{ "%.0f", DBL(0.0312), "0", },
/* Floating-point rounding */
{ "%.f", DBL(1.75), "2", },
{ "%.1f", DBL(1.75), "1.8", },
{ "%.3F", DBL(0.0625), "0.063", },
{ "%.1F", DBL(-99.99), "-100.0" },
{ "%.2F", DBL(12999.992), "12999.99" },
{ "%.2f", DBL(12999.995), "13000.00" },
/* General options with floating-point */
{ "%09.3F", DBL(123.4567), "00123.457" },
{ "%05.0f", DBL(99.99), "00100" },
{ "%+11f", DBL(0.0035678), " +0.003568" },
{ "%- 11F", DBL(0.0035678), " 0.003568 " },
/* Simple exponent cases */
{ "%e", DBL(3.876), "3.876000e+00" },
{ "%E", DBL(-38473.34254), "-3.847334E+04" },
{ "%.2e", DBL(187.2), "1.87e+02" },
{ "%.1e", DBL(-18.27), "-1.8e+01" },
{ "%e", DBL(1e-10), "1.000000e-10" },
{ "%E", DBL(3.873e180), "3.873000E+180" },
{ "%.e", DBL(0.0005), "5e-04" },
{ "%.E", DBL(128.37), "1E+02" },
{ "%.5e", DBL(912.3), "9.12300e+02" },
/* Exponent with rounding and general options */
{ "%11.3e", DBL(12.499), " 1.250e+01" },
{ "% -11.E", DBL(358.7), " 4E+02 " },
{ "%+e", DBL(14.99999), "+1.499999e+01" },
{ "%+e", DBL(14.999999), "+1.500000e+01" },
/* Exponent sizes */
{ "%.2e", DBL(1e10), "1.00e+10" },
{ "%.2e", DBL(1e100), "1.00e+100" },
{ "%.2e", DBL(1e-10), "1.00e-10" },
{ "%.2e", DBL(1e-100), "1.00e-100" },
/* Format selection and trailing zero elimination in %g */
{ "%g", DBL(124), "124" },
{ "%g", DBL(2.3), "2.3" },
{ "%g", DBL(0.0001), "0.0001" },
{ "%G", DBL(0.00001), "1E-05" },
{ "%g", DBL(834e-93), "8.34e-91" },
{ "%g", DBL(32842914732), "3.28429e+10" },
{ "%g", DBL(123456), "123456" },
{ "%G", DBL(1234567), "1.23457E+06" },
{ "%G", DBL(123000), "123000" },
/* Rounding and general options in %g */
{ "%.3g", DBL(1278), "1.28e+03" },
{ "%+.8g", DBL(1.23e5), "+123000" },
{ "%- 12.8g", DBL(123000.01), " 123000.01 " },
{ "%0.8g", DBL(123000.001), "123000" },
{ "%08.8g", DBL(123000.001), "00123000" },
{ "%g", DBL(1.234567), "1.23457" },
{ "%.1g", DBL(1.8), "2" },
/* Edge cases of significant digit count in %g */
{ "%.4g", DBL(999.93), "999.9" },
{ "%.4g", DBL(999.97), "1000" },
{ "%.5g", DBL(999.97), "999.97" },
{ "%.8G", DBL(999.97), "999.97" },
{ "%.4g", DBL(1.0001), "1", },
/* Elimination of trailing zeros in %g */
{ "%.3g", DBL(3002), "3e+03" },
{ "%.5g", DBL(0.00000034), "3.4e-07" },
{ "%.6g", DBL(999.9997), "1000" },
/* NULL terminator */
{ NULL }
};
@ -78,7 +168,7 @@ static void run_tests(struct printf_test const *tests, char answers[][16],
struct printf_test const *t = &tests[i];
#define run(TYPE, field) case TYPE: \
snprintf(answers[i], 32, t->format, t->field); \
snprintf(answers[i], 16, t->format, t->field); \
break;
switch(t->type)
@ -88,6 +178,7 @@ static void run_tests(struct printf_test const *tests, char answers[][16],
run(TYPE_STR, str)
run(TYPE_PTR, ptr)
run(TYPE_U64, u64)
run(TYPE_DBL, dbl)
}
passed[i] = !strcmp(answers[i], t->solution);
@ -121,7 +212,8 @@ static void draw(struct printf_test const *tests, char answers[][16],
int y = (i+1) * 6;
dprint( 1, y, C_BLACK, "%d", offset+i+1);
dprint(13, y, C_BLACK, "%s", t->format);
dprint(43, y, C_BLACK, "%s", answers[offset+i]);
dprint(43, y, C_BLACK, "%s", answers[offset+i][0]
? answers[offset+i] : "<empty>");
dprint(91, y, C_BLACK, "%s", passed[offset+i]?"Ok":"Err");
}
@ -145,7 +237,8 @@ static void draw(struct printf_test const *tests, char answers[][16],
row_print(i+2, 13, "%s", t->argument_as_string);
int fg = passed[offset+i] ? C_RGB(0,31,0) : C_RGB(31,0,0);
row_print_color(i+2, 29, fg, C_NONE, "%s", answers[offset+i]);
row_print_color(i+2, 29, fg, C_NONE, "%s", answers[offset+i][0]
? answers[offset+i] : "<empty>");
}
row_print(14, 1, "Passed: %d/%d", total_passed, total);

View File

@ -1,4 +1,5 @@
#include <gint/defs/util.h>
#include <gint/hardware.h>
#include <gintctl/menu.h>
#include <gintctl/util.h>
@ -7,7 +8,15 @@
void menu_init(struct menu *menu, int top, int bottom)
{
menu->len = 0;
while(menu->entries[menu->len].name) menu->len++;
for(int i = 0; menu->entries[i].name; i++)
{
int f = menu->entries[i].flags;
if(isSH3() && (f & MENU_SH4_ONLY)) continue;
if(isSH4() && (f & MENU_SH3_ONLY)) continue;
menu->entries[menu->len++] = menu->entries[i];
}
menu->offset = 0;
menu->pos = 0;

View File

@ -1,6 +1,7 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/clock.h>
#include <gint/std/stdio.h>
#include <gintctl/perf.h>
#include <gintctl/util.h>

View File

@ -1,5 +1,7 @@
#include <gint/mpu/intc.h>
#include <gint/mpu/rtc.h>
#include <gint/mpu/power.h>
#include <gint/mpu/cpg.h>
#include <gint/hardware.h>
#include <gint/display.h>
#include <gint/keyboard.h>
@ -58,9 +60,14 @@ void gintctl_regs(void)
dclear(C_WHITE);
row_title("Register browser");
row_print(2, 1, "RAMCR: %08x", *(uint32_t *)0xff000074);
row_print(3, 1, "SAR0: %08x", *(uint32_t *)0xfe008020);
row_print(4, 1, "CHCR0: %08x", *(uint32_t *)0xfe00802c);
row_print(2, 1, "%08X %08X",
SH7305_POWER.MSTPCR0.lword,
SH7305_POWER.MSTPCR2.lword);
row_print(3, 1, "%08X %08x",
SH7305_CPG.FSICLKCR.lword,
SH7305_CPG.SPUCLKCR.lword);
row_print(4, 1, "%08X",
*(volatile uint32_t *)0xff000074);
dupdate();
getkey();