From a529a8236baa11fd4fd81efdff16b46f5b537927 Mon Sep 17 00:00:00 2001 From: lephe Date: Mon, 17 Apr 2017 12:56:27 +0200 Subject: [PATCH] Just a hotfix for dimage()... fxSDK's a bit late... --- Makefile | 27 ++++++++++++++++----------- demo/gintdemo.c | 12 +++++++++--- demo/test_tales.c | 4 +++- include/gint.h | 7 +++++++ src/bopti/dimage.c | 2 +- src/bopti/gimage.c | 2 +- src/core/crt0.c | 2 +- src/core/mpu.c | 18 +++++++++--------- src/ctype/ctype_classes.c | 4 ++-- src/display/adjustRectangle.c | 2 +- src/tales/tales_internals.c | 2 ++ version | 2 +- 12 files changed, 53 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 26db109..611c024 100755 --- a/Makefile +++ b/Makefile @@ -133,20 +133,21 @@ endef #--- # Retrieve version information. -version_string := $(shell cat version | sed 's/[-.]/ /g') -version_type := $(word 1,$(version_string)) -version_major := $(word 2,$(version_string)) -version_minor := $(word 3,$(version_string)) -version_build := $(word 4,$(version_string)) +version_string = $(shell cat version | sed 's/[-.]/ /g') +version_type = $(word 1,$(version_string)) +version_major = $(word 2,$(version_string)) +version_minor = $(word 3,$(version_string)) +version_build = $(word 4,$(version_string)) -# Bump build number and make up the new version integer. -version_build := $(shell echo $$(($(version_build) + 1))) -version_letter := $(shell echo -n $(version_type) | sed -r 's/^(.).*/\1/') -version_symbol := $(shell printf '0x%02x%01x%01x%04x' "'$(version_letter)'" \ +# Make up the new version integer. +version_build_n = $(shell echo $$(($(version_build) + 1))) +version_letter = $(shell echo -n $(version_type) | sed -r 's/^(.).*/\1/') +version_symbol = $(shell printf '0x%02x%01x%01x%04x' "'$(version_letter)'" \ $(version_major) $(version_minor) $(version_build)) # Tell the linker to define the version symbol. -ldflags += -Wl,--defsym,GINT_VERSION=$(version_symbol) +demo-ldflags += -Wl,--defsym,_GINT_VERSION=$(version_symbol) +debug-ldflags += -Wl,--defsym,_GINT_VERSION=$(version_symbol) @@ -165,7 +166,7 @@ build: $(if $(VERBOSE),,@) mkdir -p $@ version: $(obj-std) $(obj-lib) - @ echo '$(version_type)-$(version_major).$(version_minor)-$(version_build)' > $@ + @ echo '$(version_type)-$(version_major).$(version_minor)-$(version_build_n)' > $@ $(obj-std) $(obj-lib) $(demo-obj): | build @@ -231,6 +232,10 @@ build/demo_%.c.o: demo/%.c $(hdr-dep) $(demo-dep) $(config) $(if $(VERBOSE),,@ printf '\e[34;1msrc \u00bb\e[0m cc $<\n') $(if $(VERBOSE),,@) $(cc) -c $< -o $@ $(demo-cflags) +build/demo_%.s.o: demo/%.s $(config) + $(if $(VERBOSE),,@ printf '\e[34;1msrc \u00bb\e[0m as $<\n') + $(if $(VERBOSE),,@) $(as) -c $< -o $@ + build/demo_font_%.bmp.o: demo/resources/font_%.bmp $(if $(VERBOSE),,@ printf '\e[36;1mres \u00bb\e[0m fxconv $<\n') $(if $(VERBOSE),,@) fxconv $< -o $@ --font -n $(patsubst demo/resources/%.bmp,res_%,$<) diff --git a/demo/gintdemo.c b/demo/gintdemo.c index 41e4d6e..7a4fee2 100644 --- a/demo/gintdemo.c +++ b/demo/gintdemo.c @@ -7,6 +7,7 @@ #include #include +#include @@ -324,7 +325,13 @@ void main_menu(int *category, int *app) extern unsigned int romdata; int gint_size = (char *)&egint - (char *)&bgint; - + // Building a version string. + char gint_version[20]; + uint32_t v = (uint32_t)&GINT_VERSION; + sprintf(gint_version, "%s-%d.%d-%d", + (v >> 24 == 'a') ? "alpha" : (v >> 24 == 'b') ? "beta" : + (v >> 24 == 'd') ? "dev" : (v >> 24 == 'r') ? "release" : "?", + (v >> 20) & 0x0f, (v >> 16) & 0x0f, v & 0xffff); static int tab = 0, index = 0, scroll = 0; // Set to 1 when interface has to be redrawn. @@ -345,8 +352,7 @@ void main_menu(int *category, int *app) switch(tab) { case 0: - print(1, 1, "Demo application"); -// print(2, 3, "gint version: %5s", GINT_VERSION_STR); + print(1, 1, "gint %s", gint_version); print(2, 4, "handler size: %5d", gint_size); print(2, 5, "mpu type: %7s", mpu); print(2, 6, "romdata: %08x", &romdata); diff --git a/demo/test_tales.c b/demo/test_tales.c index 135925d..8f26cc2 100644 --- a/demo/test_tales.c +++ b/demo/test_tales.c @@ -113,8 +113,10 @@ void test_tales(void) for(int j = 0; j < 16; j++) str[j] = 32 + (i << 4) + j; str[16] = 0; - gtext(2, 2 + i * height, str); + gtext(-3, -3 + i * height, str); } + gtext(120, 60, "Hello, World!"); + gtext(-40, 2, "Try"); gimage(0, 56, &res_opt_tales); diff --git a/include/gint.h b/include/gint.h index 57486a1..fc19d48 100644 --- a/include/gint.h +++ b/include/gint.h @@ -15,6 +15,13 @@ #include #include +// This one is defined by the linked and consists in four fields: +// - Version type, an ascii char ('a'lpha, 'b'eta, 'd'ev, 'r'elease), 8 bits +// - Major version number, 4 bits +// - Minor version numer, 4 bits +// - Build number, 16 bits +extern uint32_t GINT_VERSION; + //--- // System info provided by the library //--- diff --git a/src/bopti/dimage.c b/src/bopti/dimage.c index fe34859..27944d2 100644 --- a/src/bopti/dimage.c +++ b/src/bopti/dimage.c @@ -10,7 +10,7 @@ void dimage_part(int x, int y, image_t *img, int left, int top, int width, int height) { - if(!img || img->magic != 0x01) return; + if(!img || img->magic != 0xb7) return; structure_t s; command_t command; diff --git a/src/bopti/gimage.c b/src/bopti/gimage.c index e570634..8095be4 100644 --- a/src/bopti/gimage.c +++ b/src/bopti/gimage.c @@ -11,7 +11,7 @@ void gimage_part(int x, int y, image_t *img, int left, int top, int width, int height) { - if(!img || img->magic != 0x01) return; + if(!img || img->magic != 0xb7) return; structure_t s; command_t command; diff --git a/src/core/crt0.c b/src/core/crt0.c index c00aeb9..be9d0e4 100644 --- a/src/core/crt0.c +++ b/src/core/crt0.c @@ -55,7 +55,7 @@ __attribute__((section(".pretext.entry"))) int start(void) dg->magic = GINT_DIAGNOSTICS_MAGIC; dg->counter = dg->counter + 1; dg->mpu = mpu_unknown; - dg->version = GINT_VERSION; + dg->version = (uint32_t)&GINT_VERSION; dg->stage = stage_startup; // Exception records: what kind of exceptions / TLB faults / interrupts diff --git a/src/core/mpu.c b/src/core/mpu.c index a952e67..889e5a7 100644 --- a/src/core/mpu.c +++ b/src/core/mpu.c @@ -7,6 +7,7 @@ //--- #include +#include const mpu_t MPU_CURRENT; @@ -29,15 +30,14 @@ const mpu_t MPU_CURRENT; mpu_t getMPU(void) { // Processor version register. - volatile unsigned int *pvr = (unsigned int *)0xff000030; + volatile uint32_t *pvr = (void *)0xff000030; // Product version register. - volatile unsigned int *prr = (unsigned int *)0xff000044; + volatile uint32_t *prr = (void *)0xff000044; // Port L control register. - volatile unsigned short *plcr = (unsigned short *)0xa4000114; + volatile uint16_t *plcr = (void *)0xa4000114; // Saved value for PLCR. - unsigned short saved_plcr; - unsigned int tested_plcr; - + uint16_t saved_plcr; + uint16_t tested_plcr; // Looking for SH-3-based MPUs by testing PLCR writing access. saved_plcr = *plcr; @@ -50,12 +50,12 @@ mpu_t getMPU(void) if(tested_plcr == 0x0fff) return mpu_sh7355; // Looking for SH-4-based MPUs by testing the version registers. This - // needs to have the three upper bytes of the processor version - // register match 0x10300b : + // needs the three upper bytes of the processor version register to + // match 0x10300b : if((*pvr & 0xffffff00) != 0x10300b00) return mpu_unknown; // Now that we have an SH-4-based MPU, checking whether it is SH7305 or - // SH7724. + // SH7724, just for reference. switch(*prr & 0xfffffff0) { case 0x00002c00: diff --git a/src/ctype/ctype_classes.c b/src/ctype/ctype_classes.c index 88ff792..96ddd24 100644 --- a/src/ctype/ctype_classes.c +++ b/src/ctype/ctype_classes.c @@ -1,7 +1,7 @@ #include -// Let's save up some space and readability (That's Cake's idea, its a bit of a -// preprocessor trick but a rather nice trick). +// Let's save up some space and readability (that's Cake's idea, it's a bit of +// a preprocessor trick - but a rather nice trick). #define r4(x) (x), (x), (x), (x) #define r5(x) r4(x), (x) #define r6(x) r5(x), (x) diff --git a/src/display/adjustRectangle.c b/src/display/adjustRectangle.c index f46f9b2..5d2f482 100644 --- a/src/display/adjustRectangle.c +++ b/src/display/adjustRectangle.c @@ -7,7 +7,7 @@ - x1 < x2 - y1 < y2 which is needed when working with screen rectangles. - Returns non-zero if the rectangle is outside the screen. + Returns non-zero if the rectangle is entirely outside the screen. */ int adjustRectangle(int *x1, int *y1, int *x2, int *y2) { diff --git a/src/tales/tales_internals.c b/src/tales/tales_internals.c index e6dec37..b39b4a8 100644 --- a/src/tales/tales_internals.c +++ b/src/tales/tales_internals.c @@ -234,6 +234,8 @@ void render(int x, int y, const char *str, void (*op)(OPERATE_ARGS)) // Computing the initial operator offset to have 32-aligned operators. // This allows to write directly video ram longs instead of having to // shift operators, and do all the vram operation twice. + // I double-checked that this operation is still valid when x is + // negative. available = 32 - (x & 31); x &= ~31; diff --git a/version b/version index 91cef21..dcdacc6 100644 --- a/version +++ b/version @@ -1 +1 @@ -beta-0.9-289 +beta-0.9-302