Skip to content
Snippets Groups Projects
Commit f3a56457 authored by Fang Lu's avatar Fang Lu
Browse files

resources - bug fixes

parent ff035d30
No related branches found
No related tags found
No related merge requests found
...@@ -115,9 +115,9 @@ ...@@ -115,9 +115,9 @@
#define mpeg_read_ptr (void *)(IORD_32DIRECT(ISD_BASE, MPEG_READ_PTR)) #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) #define mpeg_read_reset(val) IOWR_32DIRECT(ISD_BASE, MPEG_READ_ADDR, val)
// Sprite: W // Image Resources: W
// Trig: ADDR // Trig: ADDR
// Ready: DEST // Ready: ADDR
#define MPEG_IMG_ADDR 52 // - 55 #define MPEG_IMG_ADDR 52 // - 55
#define MPEG_IMG_WIDTH 56 // - 57 #define MPEG_IMG_WIDTH 56 // - 57
#define MPEG_IMG_HEIGHT 58 // - 59 #define MPEG_IMG_HEIGHT 58 // - 59
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
#define wr_audio_buffer2(val1,val2) IOWR_32DIRECT(ISD_BASE, AUDIO_BUFFER2+(val1<<2),val2) #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_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 \ #define interprocess_reset \
for (int _i=0; _i<4096; _i++)\ for (int _i=0; _i<4096; _i++)\
......
/*
#include "font.h" #include "font.h"
#include <stdio.h> #include <stdio.h>
...@@ -11,8 +10,8 @@ ...@@ -11,8 +10,8 @@
void gl_text(gl_text_ctx *context, const char *str, int x, int y) { void gl_text(gl_text_ctx *context, const char *str, int x, int y) {
int idx; int idx;
for (char *c = str; *c; c++) { for (const char *c = str; *c; c++) {
idx = c - ' '; idx = *c - ' ';
if (idx < 0) { if (idx < 0) {
// Render char 32 (unknown symbol) // Render char 32 (unknown symbol)
context->x_[0][context->count_[0]] = x; 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) { ...@@ -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) { void gl_text_flush(gl_text_ctx *context) {
gl_wait(); gl_wait();
for (int c = 0; c < 96; c++) { for (int c = 0; c < 96; c++) {
GL_IOWR(GL_ARGS, 0, context->font->font[i]); GL_IOWR(GL_ARGS, 0, context->font->font[c]);
GL_IOWR(GL_ARGS, 1, gl_make_point(context->font->widths[i], context->font->height)); GL_IOWR(GL_ARGS, 1, gl_make_point(context->font->widths[c],
context->font->height));
int argptr = 2, cptr = context->count_[c]; int argptr = 2, cptr = context->count_[c];
while (cptr --> 0) { 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) { if (argptr == 8) {
// Flush // Flush
GL_IOWR(GL_COMMAND, 0, GL_CMD_IMAGE); GL_IOWR(GL_COMMAND, 0, GL_CMD_IMAGE);
...@@ -60,4 +61,3 @@ void gl_text_flush(gl_text_ctx *context) { ...@@ -60,4 +61,3 @@ void gl_text_flush(gl_text_ctx *context) {
void gl_text_clear(gl_text_ctx *context) { void gl_text_clear(gl_text_ctx *context) {
memset(context->count_, 0, sizeof(context->count_)); memset(context->count_, 0, sizeof(context->count_));
} }
*/
#ifndef FONT_H_ #ifndef FONT_H_
#define FONT_H_ #define FONT_H_
#include "../sdcard/osufs/osufs.h" #include "../osufs.h"
#include <inttypes.h> #include <inttypes.h>
typedef struct gl_text_ctx_t { typedef struct gl_text_ctx_t {
......
...@@ -18,7 +18,8 @@ meta-> entry ## _begin = (uint32_t) mptr; ...@@ -18,7 +18,8 @@ meta-> entry ## _begin = (uint32_t) mptr;
#define RES_LOAD_IMAGE(entry) \ #define RES_LOAD_IMAGE(entry) \
mpeg_img_read(meta->entry, meta-> entry ## _w, meta-> entry ## _h, sram_ptr);\ 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) { void resource_load(osu_meta *meta) {
...@@ -80,12 +81,16 @@ void resource_load(osu_meta *meta) { ...@@ -80,12 +81,16 @@ void resource_load(osu_meta *meta) {
h = meta->selection_h; h = meta->selection_h;
len = w * h; len = w * h;
mpeg_img_read(meta->selection_mod, w, h, sram_ptr); mpeg_img_read(meta->selection_mod, w, h, sram_ptr);
meta->selection_mod = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->selection_mod_over, w, h, sram_ptr); mpeg_img_read(meta->selection_mod_over, w, h, sram_ptr);
meta->selection_mod_over = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->selection_random, w, h, sram_ptr); mpeg_img_read(meta->selection_random, w, h, sram_ptr);
meta->selection_random = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->selection_random_over, w, h, sram_ptr); mpeg_img_read(meta->selection_random_over, w, h, sram_ptr);
meta->selection_random_over = sram_ptr;
sram_ptr += len; sram_ptr += len;
...@@ -93,46 +98,51 @@ void resource_load(osu_meta *meta) { ...@@ -93,46 +98,51 @@ void resource_load(osu_meta *meta) {
h = meta->mod_h; h = meta->mod_h;
len = w * h; len = w * h;
mpeg_img_read(meta->mod_auto, w, h, sram_ptr); mpeg_img_read(meta->mod_auto, w, h, sram_ptr);
meta->mod_auto = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->mod_nofail, w, h, sram_ptr); mpeg_img_read(meta->mod_nofail, w, h, sram_ptr);
meta->mod_nofail = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->mod_easy, w, h, sram_ptr); mpeg_img_read(meta->mod_easy, w, h, sram_ptr);
meta->mod_easy = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->mod_hardrock, w, h, sram_ptr); mpeg_img_read(meta->mod_hardrock, w, h, sram_ptr);
meta->mod_hardrock = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->mod_hidden, w, h, sram_ptr); mpeg_img_read(meta->mod_hidden, w, h, sram_ptr);
meta->mod_hidden = sram_ptr;
sram_ptr += len; sram_ptr += len;
mpeg_img_read(meta->mod_suddendeath, w, h, sram_ptr); mpeg_img_read(meta->mod_suddendeath, w, h, sram_ptr);
meta->mod_suddendeath = sram_ptr;
sram_ptr += len; sram_ptr += len;
meta->font_12 = resource_load_font((meta->font_12), &sram_ptr);
meta->font_16 = resource_load_font((meta->font_16), &sram_ptr);
sram_ptr = resource_load_font((meta->font_12), sram_ptr); meta->font_24 = resource_load_font((meta->font_24), &sram_ptr);
sram_ptr = resource_load_font((meta->font_16), sram_ptr); meta->font_score = resource_load_font((meta->font_score), &sram_ptr);
sram_ptr = resource_load_font((meta->font_24), sram_ptr);
sram_ptr = resource_load_font((meta->font_score), sram_ptr);
if (sram_ptr > 0xfffff) { if (sram_ptr > 0xfffff) {
printf("SEVERE: SRAM overflow\n"); 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)); 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) { if (strncmp(font->magic, "oFNT", 4) != 0) {
printf("CRITICAL: invalid font magic!\n"); printf("CRITICAL: invalid font magic!\n");
return sram_ptr; return 0;
} }
for (int i=0; i<96; i++) { for (int i=0; i<96; i++) {
if (font->font[i]) { if (font->font[i]) {
mpeg_img_read(font->font[i], font->widths[i], font->height, sram_ptr); mpeg_img_read(font->font[i], font->widths[i], font->height, *sram_ptr);
sram_ptr += font->widths[i] * font->height; font->font[i] = *sram_ptr;
*sram_ptr += font->widths[i] * font->height;
} }
} }
return sram_ptr; return (uint32_t) font;
} }
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
#include "osufs.h" #include "osufs.h"
void resource_load(osu_meta *meta); 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 #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment