diff --git a/software/interprocess/interprocess.h b/software/interprocess/interprocess.h index f5e00905262113daf5d30be511be81fd0a2577b5..a8262df8bd76f0a3ed95af1cf36ba944c72e8ee5 100644 --- a/software/interprocess/interprocess.h +++ b/software/interprocess/interprocess.h @@ -115,9 +115,9 @@ #define mpeg_read_ptr (void *)(IORD_32DIRECT(ISD_BASE, MPEG_READ_PTR)) #define mpeg_read_reset(val) IOWR_32DIRECT(ISD_BASE, MPEG_READ_ADDR, val) -// Sprite: W +// Image Resources: W // Trig: ADDR -// Ready: DEST +// Ready: ADDR #define MPEG_IMG_ADDR 52 // - 55 #define MPEG_IMG_WIDTH 56 // - 57 #define MPEG_IMG_HEIGHT 58 // - 59 @@ -151,7 +151,7 @@ #define wr_audio_buffer2(val1,val2) IOWR_32DIRECT(ISD_BASE, AUDIO_BUFFER2+(val1<<2),val2) #define rd_audio_buffer1_8(val1) IORD_8DIRECT(ISD_BASE, AUDIO_BUFFER1+val1) -#define rd_audio_buffer1_16(val1) IORD_8DIRECT(ISD_BASE, AUDIO_BUFFER1+val1<<1) +#define rd_audio_buffer1_16(val1) IORD_16DIRECT(ISD_BASE, AUDIO_BUFFER1+(val1<<1)) #define interprocess_reset \ for (int _i=0; _i<4096; _i++)\ diff --git a/software/osu_main/src/gl/font.c b/software/osu_main/src/gl/font.c index d199ce9bdf2ef1f310903031b9e14f66900409e1..ff6981f2e186b83b3ea5fffea65c820f8af6b555 100644 --- a/software/osu_main/src/gl/font.c +++ b/software/osu_main/src/gl/font.c @@ -1,4 +1,3 @@ -/* #include "font.h" #include <stdio.h> @@ -11,8 +10,8 @@ void gl_text(gl_text_ctx *context, const char *str, int x, int y) { int idx; - for (char *c = str; *c; c++) { - idx = c - ' '; + for (const char *c = str; *c; c++) { + idx = *c - ' '; if (idx < 0) { // Render char 32 (unknown symbol) context->x_[0][context->count_[0]] = x; @@ -35,11 +34,13 @@ void gl_text(gl_text_ctx *context, const char *str, int x, int y) { void gl_text_flush(gl_text_ctx *context) { gl_wait(); for (int c = 0; c < 96; c++) { - GL_IOWR(GL_ARGS, 0, context->font->font[i]); - GL_IOWR(GL_ARGS, 1, gl_make_point(context->font->widths[i], context->font->height)); + GL_IOWR(GL_ARGS, 0, context->font->font[c]); + GL_IOWR(GL_ARGS, 1, gl_make_point(context->font->widths[c], + context->font->height)); int argptr = 2, cptr = context->count_[c]; while (cptr --> 0) { - GL_IOWR(GL_ARGS, argptr++, gl_make_point(context->x_[cptr], context->y_[cptr])); + GL_IOWR(GL_ARGS, argptr++, + gl_make_point(context->x_[c][cptr], context->y_[c][cptr])); if (argptr == 8) { // Flush GL_IOWR(GL_COMMAND, 0, GL_CMD_IMAGE); @@ -60,4 +61,3 @@ void gl_text_flush(gl_text_ctx *context) { void gl_text_clear(gl_text_ctx *context) { memset(context->count_, 0, sizeof(context->count_)); } -*/ diff --git a/software/osu_main/src/gl/font.h b/software/osu_main/src/gl/font.h index b4b875b1a8fe16deecbb8df2a73eed43b986f443..15fbab198def31654ac73ad78f56c8eeb3dadef3 100644 --- a/software/osu_main/src/gl/font.h +++ b/software/osu_main/src/gl/font.h @@ -1,7 +1,7 @@ #ifndef FONT_H_ #define FONT_H_ -#include "../sdcard/osufs/osufs.h" +#include "../osufs.h" #include <inttypes.h> typedef struct gl_text_ctx_t { diff --git a/software/osu_main/src/resources.c b/software/osu_main/src/resources.c index 115534b690f70e0c0520241efd90045e89dc7a87..b5a80a8a895472bbd367f7aefcce9ff7a02b4d24 100644 --- a/software/osu_main/src/resources.c +++ b/software/osu_main/src/resources.c @@ -18,7 +18,8 @@ meta-> entry ## _begin = (uint32_t) mptr; #define RES_LOAD_IMAGE(entry) \ mpeg_img_read(meta->entry, meta-> entry ## _w, meta-> entry ## _h, sram_ptr);\ -sram_ptr += meta-> entry ## _w * meta-> entry ## _h; +sram_ptr += meta-> entry ## _w * meta-> entry ## _h;\ +meta->entry = sram_ptr; void resource_load(osu_meta *meta) { @@ -80,12 +81,16 @@ void resource_load(osu_meta *meta) { h = meta->selection_h; len = w * h; mpeg_img_read(meta->selection_mod, w, h, sram_ptr); + meta->selection_mod = sram_ptr; sram_ptr += len; mpeg_img_read(meta->selection_mod_over, w, h, sram_ptr); + meta->selection_mod_over = sram_ptr; sram_ptr += len; mpeg_img_read(meta->selection_random, w, h, sram_ptr); + meta->selection_random = sram_ptr; sram_ptr += len; mpeg_img_read(meta->selection_random_over, w, h, sram_ptr); + meta->selection_random_over = sram_ptr; sram_ptr += len; @@ -93,46 +98,51 @@ void resource_load(osu_meta *meta) { h = meta->mod_h; len = w * h; mpeg_img_read(meta->mod_auto, w, h, sram_ptr); + meta->mod_auto = sram_ptr; sram_ptr += len; mpeg_img_read(meta->mod_nofail, w, h, sram_ptr); + meta->mod_nofail = sram_ptr; sram_ptr += len; mpeg_img_read(meta->mod_easy, w, h, sram_ptr); + meta->mod_easy = sram_ptr; sram_ptr += len; mpeg_img_read(meta->mod_hardrock, w, h, sram_ptr); + meta->mod_hardrock = sram_ptr; sram_ptr += len; mpeg_img_read(meta->mod_hidden, w, h, sram_ptr); + meta->mod_hidden = sram_ptr; sram_ptr += len; mpeg_img_read(meta->mod_suddendeath, w, h, sram_ptr); + meta->mod_suddendeath = sram_ptr; sram_ptr += len; - - - sram_ptr = resource_load_font((meta->font_12), sram_ptr); - sram_ptr = resource_load_font((meta->font_16), sram_ptr); - sram_ptr = resource_load_font((meta->font_24), sram_ptr); - sram_ptr = resource_load_font((meta->font_score), sram_ptr); + meta->font_12 = resource_load_font((meta->font_12), &sram_ptr); + meta->font_16 = resource_load_font((meta->font_16), &sram_ptr); + meta->font_24 = resource_load_font((meta->font_24), &sram_ptr); + meta->font_score = resource_load_font((meta->font_score), &sram_ptr); if (sram_ptr > 0xfffff) { printf("SEVERE: SRAM overflow\n"); } - printf("Done loading. SRAM usage is %x", sram_ptr); + printf("Done loading. SRAM usage is %lx", sram_ptr); } -uint32_t resource_load_font(void *fontp, uint32_t sram_ptr) { +uint32_t resource_load_font(uint32_t fontp, uint32_t *sram_ptr) { osu_font *font = malloc(sizeof(osu_font)); - mpeg_read((uint32_t)fontp, 1, (uint32_t)font); + mpeg_read(fontp, 1, (uint32_t) font); if (strncmp(font->magic, "oFNT", 4) != 0) { printf("CRITICAL: invalid font magic!\n"); - return sram_ptr; + return 0; } for (int i=0; i<96; i++) { if (font->font[i]) { - mpeg_img_read(font->font[i], font->widths[i], font->height, sram_ptr); - sram_ptr += font->widths[i] * font->height; + mpeg_img_read(font->font[i], font->widths[i], font->height, *sram_ptr); + font->font[i] = *sram_ptr; + *sram_ptr += font->widths[i] * font->height; } } - return sram_ptr; + return (uint32_t) font; } diff --git a/software/osu_main/src/resources.h b/software/osu_main/src/resources.h index 000f48e695248a4715aeb6da66c6792d333a3c4e..9676aab656bc442abf2fedb8159e1289aa25f498 100644 --- a/software/osu_main/src/resources.h +++ b/software/osu_main/src/resources.h @@ -4,6 +4,6 @@ #include "osufs.h" void resource_load(osu_meta *meta); -uint32_t resource_load_font(void *font, uint32_t sram_ptr); +uint32_t resource_load_font(uint32_t fontp, uint32_t *sram_ptr); #endif