Combine le code des deux anciennes viewImg pour un resultat crossplatform Compilation: Il suffit comme pour les anciennes de faire `fxsdk build-fx` ou `fxsdk build-cg` *Note: Compatibilité cg pas encore testée mais ça devrait etre bon. Si jamas ça ne marge pas il faudra éventuellement rajouter une police mais ce sera à voir ^^master
@ -0,0 +1,194 @@ | |||
#! /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) | |||
CFLAGSCG := $(CFLAGS) $(CFLAGS_CG) $(INCLUDE) | |||
# 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) | |||
# | |||
# 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 $@ | |||
build-cg/%.s.o: %.s | |||
@ mkdir -p $(dir $@) | |||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ | |||
# Preprocessed assembler sources | |||
build-fx/%.S.o: %.S | |||
@ mkdir -p $(dir $@) | |||
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(INCLUDE) | |||
build-cg/%.S.o: %.S | |||
@ mkdir -p $(dir $@) | |||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE) | |||
# 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) | |||
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 0.25; done | |||
@ while ! mount /dev/Prizm1; do sleep 0.25; done | |||
@ rm -f /mnt/prizm/$< | |||
@ cp $< /mnt/prizm | |||
@ umount /dev/Prizm1 | |||
@- eject /dev/Prizm1 | |||
.PHONY: all all-fx all-cg clean distclean install-fx install-cg |
@ -0,0 +1,85 @@ | |||
#--- | |||
# fxSDK project configuration file for ViewImg | |||
#--- | |||
#--- | |||
# fxSDK project configuration file for aaa | |||
#--- | |||
# Project name, should be at most 8 bytes long. | |||
# (You can also specify NAME_G1A or NAME_G3A to override individually.) | |||
NAME := ViewImg | |||
# 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 = @VIEWIMG | |||
# 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-fx.png | |||
# fx-CG 50 icon locations | |||
ICON_CG_UNS = assets-cg/icon-cg-uns.png | |||
ICON_CG_SEL = assets-cg/icon-cg-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<>. | |||
INCLUDE := -I include | |||
# 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 := -llog-fx | |||
# Base linker flags for the fxSDK, you usually want to keep these. | |||
LDFLAGS_FX := -T fx9860g.ld -lgint-fx $(LIBS) -lgint-fx -lgcc | |||
LDFLAGS_CG := -T fxcg50.ld -lgint-cg $(LIBS) -lgint-cg -lgcc | |||
# Additional linker flags, if you need any. | |||
LDFLAGS := | |||
# Additional platform-specific linker flags. | |||
LDFLAGS_FX += -Wl,-Map=build-fx/map | |||
LDFLAGS_CG += -Wl,-Map=build-cg/map | |||
# Here you can add fxconv options for each converted file, individually. | |||
# The syntax is "<type>.<file>". For example, to specify the parameters for a | |||
# font name "hexa.png", you might write: | |||
# | |||
# FONT.hexa.png = charset:print grid:size:3x5 grid.padding:1 | |||
FONT.odyssee.png = charset:print grid.size:5x5 grid.padding:1 proportionnal:true |
@ -0,0 +1,199 @@ | |||
/* | |||
Nom : ViewImg (visionneuse d'image) | |||
Version : 1.1b | |||
Dernière modification : 1 Semptembre 2019 | |||
Mode d'emploi : | |||
Créez une image de 128 pxl par 64 * nb_img + nb_img - 1 pxl. 'nb_img' étant le nombre d'image que vous souhaitez visionner. | |||
Renseignez ce numéro dans la variable 'nb_img'. | |||
Une fois votre image créée, placez dedans toutes les images que vous souhaitez voir en colonne. Prenez garde à bien laiser un pixel de séparation entre les images. | |||
Placez l'image *.png dans le dossier du projet : ViewImg/assets-fx/img/. | |||
*/ | |||
/* ----------- */ | |||
/* - IMPORTS - */ | |||
/* ----------- */ | |||
#include <gint/display.h> | |||
#include <gint/keyboard.h> | |||
#include <gint/gray.h> | |||
#include <gint/std/stdio.h> | |||
#include <gint/std/string.h> | |||
/* ------------- */ | |||
/* - CONSTANTES - */ | |||
/* ------------- */ | |||
#ifdef FX9860G | |||
#define NB_IMG 8 | |||
#else | |||
#define NB_IMG 2 | |||
#endif | |||
/* -------------- */ | |||
/* - PROTOTYPES - */ | |||
/* -------------- */ | |||
//reglage_gris : Permet de régler les teintes de gris | |||
void reglage_gris(int * reglage); | |||
int main(void) | |||
{ | |||
// Declaration des images custom | |||
extern image_t img_images; | |||
#ifdef FX9860G | |||
// Spécifique aux fx9860g : on charge la font custom et on la choisit par défaut | |||
extern font_t font_odyssee; | |||
dfont(&font_odyssee); | |||
#endif | |||
/* | |||
fin : sert à quitter | |||
img : l'index de l'image à afficher, permet d'afficher la bonne image | |||
key : récupère les entrées clavier | |||
no : booleen qui sert à afficher ou non l'index de l'image en cours | |||
light : valeur du gris clair | |||
dark : valeur du gris foncé | |||
NB_IMG : nombre total d'image disponibles | |||
*/ | |||
int fin = 0, img = 1, key = 0, texte = 0; | |||
char str[19]; | |||
#ifdef FX9860G | |||
// réglages du moteur de gris | |||
int reglage[2] = { 920, 1350 }; | |||
//On lance le moteur de gris, on initialise le gris et tant que l'utilisateur ne quitte pas… | |||
gray_start(); | |||
gray_delays(reglage[0], reglage[1]); | |||
#endif | |||
while (fin == 0) | |||
{ | |||
//On actualise la chaine de caractère qui affiche l'index de l'image | |||
sprintf(str, "%d/%d ViewImg v. 1.2", img, NB_IMG); | |||
// Effacement de l'écran | |||
#ifdef FX9860G | |||
gclear(C_WHITE); // (Fonction du moteur de gris) | |||
#else | |||
dclear(C_WHITE); | |||
#endif | |||
// Affichage de l'image et si besoin, on affiche aussi l'index de l'image | |||
// Ensuite on met à jour l'écran | |||
#ifdef FX9860G | |||
gsubimage(0, 0, &img_images, 0, (64 * (img - 1)) + (img - 1), 128, 64, 0); | |||
if (texte) gtext(0, 0, str, C_BLACK, C_WHITE); | |||
gupdate(); | |||
#else | |||
dsubimage(0, 0, &img_images, 0, (216 * (img - 1) + (img - 1)), 384, 216, 0); | |||
if (texte) dtext(0, 0, str, C_BLACK, C_WHITE); | |||
dupdate(); | |||
#endif | |||
switch (getkey().key) | |||
{ | |||
case KEY_LEFT: | |||
//Si on ne regarde pas la première image on affiche l'image juste avant | |||
if (img > 1) img --; | |||
break; | |||
case KEY_RIGHT: | |||
//Si on ne regarde pas la dernière image, on affiche l'image juste après | |||
if (img < NB_IMG) img ++; | |||
break; | |||
case KEY_OPTN: | |||
//Booleen pour afficher l'index ou pas | |||
texte = (texte + 1) % 2; | |||
break; | |||
#ifdef FX9860G | |||
case KEY_VARS: | |||
reglage_gris(reglage); | |||
break; | |||
#endif | |||
case KEY_EXIT: | |||
//On quitte le programme | |||
fin = 1; | |||
break; | |||
} | |||
} | |||
#ifdef FX9860G | |||
//On éteint le moteur de gris avant de sortir | |||
gray_stop(); | |||
#endif | |||
return 0; | |||
} | |||
#ifdef FX9860G | |||
void reglage_gris(int * reglage) | |||
{ | |||
const int ancien_reglage[2] = {reglage[0], reglage[1]}; | |||
int ligne = 0, fin = 0; | |||
extern image_t img_reglage; | |||
char dark[10], light[10]; | |||
while (!fin) | |||
{ | |||
/* On met à jour les nuances de gris | |||
* On nettoye la VRAM et on affiche l'image | |||
* On affiche les valeurs du gris avec les flèches de modifications après avoir modifié les chaines de caactères | |||
* On affiche tout ça et on enregistre les inputs clavier */ | |||
gray_delays(reglage[0], reglage[1]); | |||
gclear(C_WHITE); | |||
gimage(0, 0, &img_reglage); | |||
if (ligne == 0) | |||
{ | |||
sprintf(dark, "< %d >", reglage[1]); | |||
sprintf(light, " %d ", reglage[0]); | |||
} | |||
else | |||
{ | |||
sprintf(dark, " %d ", reglage[1]); | |||
sprintf(light, "< %d >", reglage[0]); | |||
} | |||
gtext(41, 24, dark, C_BLACK, C_NONE); | |||
gtext(41, 33, light, C_BLACK, C_NONE); | |||
gupdate(); | |||
//On analyse l'input et on agit en conséquence | |||
switch (getkey().key) | |||
{ | |||
case KEY_LEFT: | |||
reglage[ligne] -= 1; | |||
break; | |||
case KEY_RIGHT: | |||
reglage[ligne] += 1; | |||
break; | |||
case KEY_UP: | |||
if (ligne == 1) ligne = 0; | |||
break; | |||
case KEY_DOWN: | |||
if (ligne == 0) ligne = 1; | |||
break; | |||
case KEY_EXIT: | |||
memcpy(reglage, ancien_reglage, 2 * sizeof(int)); | |||
fin = 1; | |||
break; | |||
case KEY_EXE: | |||
fin = 1; | |||
break; | |||
} | |||
} | |||
//On met à jour les valeurs de gris | |||
gray_delays(reglage[0], reglage[1]); | |||
} | |||
#endif |