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

background - software test

parent 0d009b07
No related branches found
No related tags found
No related merge requests found
......@@ -154,6 +154,7 @@ C_SRCS += src/sdcard/terasic_sdcard/crc7.c
C_SRCS += src/sdcard/terasic_sdcard/sd_hal.c
C_SRCS += src/sdcard/terasic_sdcard/sd_lib.c
C_SRCS += src/sdcard/terasic_sdcard/sd_protocol.c
C_SRCS += src/util.c
CXX_SRCS :=
ASM_SRCS :=
......@@ -176,7 +177,7 @@ APP_CFLAGS_UNDEFINED_SYMBOLS :=
APP_CFLAGS_OPTIMIZATION := -O0
APP_CFLAGS_DEBUG_LEVEL := -g
APP_CFLAGS_WARNINGS := -Wall
APP_CFLAGS_USER_FLAGS := -DDEBUG_SDCARD
APP_CFLAGS_USER_FLAGS :=
APP_ASFLAGS_USER :=
APP_LDFLAGS_USER :=
......
......@@ -16,6 +16,8 @@
#include "sdcard/sdcard.h"
#include "util.h"
int main() {
printf("Hello world\n");
......@@ -27,41 +29,15 @@ int main() {
size_t t_end = clock();
printf("Bench: 65536 loops took %d ms\n", (t_end-t_start));
// Background
GL_PLWR(0, 0xffffff);
GL_PLWR(1, 0xff0000);
GL_PLWR(2, 0x00ff00);
GL_PLWR(3, 0x0000ff);
GL_PLWR(4, 0x66ccff);
GL_PLWR(5, 0xccffcc);
gl_background_dim(128);
printf("Written color 0: %x\n", GL_PLRD(0));
printf("Written color 1: %x\n", GL_PLRD(1));
printf("Written color 2: %x\n", GL_PLRD(2));
printf("Written color 3: %x\n", GL_PLRD(3));
printf("Written color 4: %x\n", GL_PLRD(4));
printf("Written color 5: %x\n", GL_PLRD(5));
for (int i=0; i<640; i+=2) {
for (int j=0; j<480; j++) {
if (i&0x8) {
GL_SRAMWR(GL_SRAM_BGBASE + gl_make_point_8bit(i,j), (4<<8)|4);
} else {
GL_SRAMWR(GL_SRAM_BGBASE + gl_make_point_8bit(i,j), (5<<8)|5);
}
}
}
// Test sdcard
osu_init_device();
osu_meta o_meta;
char o_meta_buf[516];
osu_meta *p_meta = ALIGN_32(&o_meta_buf);
while(1){
if (osu_read_meta(&o_meta)){
if (osu_read_meta(p_meta)){
printf("Sdcard mount success!\n");
printf("magic:%c%c%c%c\n",o_meta.magic[0],o_meta.magic[1],o_meta.magic[2],o_meta.magic[3]);
printf("Song Count:%d\n", o_meta.songs);
printf("magic:%c%c%c%c\n",p_meta->magic[0],p_meta->magic[1],p_meta->magic[2],p_meta->magic[3]);
printf("Song Count:%d\n", p_meta->songs);
break;
}else{
printf("Failed to mount the SDCARD!\r\nPlease retry!\r\n");
......@@ -71,8 +47,44 @@ int main() {
} // while
char o_song_buf[516];
osu_song *p_song = ALIGN_32(&o_song_buf);
osu_read_song(1, p_song);
// Background
gl_background_dim(128);
char buf_buf[516];
uint8_t *buf = ALIGN_32(&buf_buf);
osu_read_song(p_song->cover_begin, buf);
if (strncasecmp(buf, "PLT", 3)!=0) {
printf("Invalid palette magic: %c%c%c\n", buf[0], buf[1], buf[2]);
}
for (int i=0; i<128; i++) {
uint32_t c = (buf[i*3+3]<<16) | (buf[i*3+4]<<8) | buf[i*3+5];
printf("Writing %x -> #%06x\n",i+128,c);
GL_PLWR(i+128, c);
}
uint8_t c1, c2;
int bptr=512, sdptr = p_song->cover_begin;
for (int j=0; j<480; j++) {
for (int i=0; i<640; i+=2) {
if (bptr >= 512) {
// Fetch next
osu_read_song(++sdptr, buf);
bptr = 0;
}
c1 = buf[bptr++];
c2 = buf[bptr++];
GL_SRAMWR(GL_SRAM_BGBASE+gl_make_point_8bit(i,j), (c1<<8)|c2);
}
}
uint16_t dim=0;
uint32_t dim=0;
while (1) {
/*
for (int i=0; i<2; i++) {
......@@ -110,13 +122,13 @@ int main() {
}
*/
dim++;
if ((dim>>4) > 128) {
if ((dim>>8) > 128) {
dim = 0;
}
gl_background_dim(dim>>4);
gl_rect(100, 100, 105, 105, gl_make_color(0xffccccc), gl_make_color(0xffccccc), gl_make_color(0xff0000), 1);
gl_circle(200,200,50,gl_make_color(0x66ccff),gl_make_color(0x66ccff), gl_make_color(0xffffff), 1);
gl_polygon(300,100,400,300,200,170,400,230, gl_make_color(0x66ff66), gl_make_color(0x66ff66), 1);
// gl_background_dim(dim>>8);
// gl_rect(100, 100, 105, 105, gl_make_color(0xffccccc), gl_make_color(0xffccccc), gl_make_color(0xff0000), 1);
// gl_circle(200,200,50,gl_make_color(0x66ccff),gl_make_color(0x66ccff), gl_make_color(0xffffff), 1);
// gl_polygon(300,100,400,300,200,170,400,230, gl_make_color(0x66ff66), gl_make_color(0x66ff66), 1);
gl_finalize_frame();
gl_finalize_wait();
}
......
......@@ -18,13 +18,102 @@ extern "C" {
#include <stdbool.h>
#include <unistd.h>
typedef struct __attribute__((__packed__)) osu_meta_t {
char magic[4]; // 0 - 3
uint16_t songs; // 4 - 5
uint16_t available_block; // 6 - 7
typedef struct __attribute__((__packed__)) osu_meta_t {
char magic[4]; // 0 - 3
uint16_t songs; // 4 - 5
uint32_t available_block; // 6 - 9
char meta_padding[6]; // 10 - 15
// Resources
// Sounds
uint32_t applause_begin; // 16 - 19
uint32_t failsnd_begin; // 20 - 23
uint16_t applause_len; // 24 - 25
uint16_t failsnd_len; // 26 - 27
uint32_t spinnerspin_begin; // 28 - 31
uint32_t spinnerbonus_begin; // 32 - 35
uint16_t spinnerspin_len; // 36 - 37
uint16_t spinnerbonus_len; // 38 - 39
uint32_t menuclick_begin; // 40 - 43
uint32_t menuback_begin; // 44 - 47
uint16_t menuclick_len; // 48 - 49
uint16_t menuback_len; // 50 - 51
uint32_t menuhit_begin; // 52 - 55
uint32_t combobreak_begin; // 56 - 59
uint16_t menuhit_len; // 60 - 61
uint16_t combobreak_len; // 62 - 63
uint32_t drum_hitclap_begin; // 64 - 67
uint32_t drum_hitfinish_begin; // 68 - 71
uint16_t drum_hitclap_len; // 72 - 73
uint16_t drum_hitfinish_len; // 74 - 75
uint32_t drum_hitnormal_begin; // 76 - 79
uint32_t drum_hitwhistle_begin; // 80 - 83
uint16_t drum_hitnormal_len; // 84 - 85
uint16_t drum_hitwhistle_len; // 86 - 87
uint32_t drum_sliderslide_begin; // 88 - 91
uint32_t drum_slidertick_begin; // 92 - 95
uint16_t drum_sliderslide_len; // 96 - 97
uint16_t drum_slidertick_len; // 98 - 99
uint32_t drum_sliderwhistle_begin; // 100 - 103
uint32_t drum_padding_begin; // 104 - 107
uint16_t drum_sliderwhistle_len; // 108 - 109
uint16_t drum_padding_len; // 110 - 111
uint32_t normal_hitclap_begin; // 112 - 115
uint32_t normal_hitfinish_begin; // 116 - 119
uint16_t normal_hitclap_len; // 120 - 121
uint16_t normal_hitfinish_len; // 122 - 123
uint32_t normal_hitnormal_begin; // 124 - 127
uint32_t normal_hitwhistle_begin; // 128 - 131
uint16_t normal_hitnormal_len; // 132 - 133
uint16_t normal_hitwhistle_len; // 134 - 135
uint32_t normal_sliderslide_begin; // 136 - 139
uint32_t normal_slidertick_begin; // 140 - 143
uint16_t normal_sliderslide_len; // 144 - 145
uint16_t normal_slidertick_len; // 146 - 147
uint32_t normal_sliderwhistle_begin; // 148 - 151
uint32_t normal_padding_begin; // 152 - 155
uint16_t normal_sliderwhistle_len; // 156 - 157
uint16_t normal_padding_len; // 158 - 159
uint32_t soft_hitclap_begin; // 160 - 163
uint32_t soft_hitfinish_begin; // 164 - 167
uint16_t soft_hitclap_len; // 168 - 169
uint16_t soft_hitfinish_len; // 170 - 171
uint32_t soft_hitnormal_begin; // 172 - 175
uint32_t soft_hitwhistle_begin; // 176 - 179
uint16_t soft_hitnormal_len; // 180 - 181
uint16_t soft_hitwhistle_len; // 182 - 183
uint32_t soft_sliderslide_begin; // 184 - 187
uint32_t soft_slidertick_begin; // 188 - 191
uint16_t soft_sliderslide_len; // 192 - 193
uint16_t soft_slidertick_len; // 194 - 195
uint32_t soft_sliderwhistle_begin; // 196 - 199
uint32_t soft_padding_begin; // 200 - 203
uint16_t soft_sliderwhistle_len; // 204 - 205
uint16_t soft_padding_len; // 206 - 207
// Image resources
uint32_t test_img;
uint16_t test_w;
uint16_t test_h;
char _padding[504]; // 8 - 511
} osu_meta;
char _padding[296]; // 10 - 511
} osu_meta;
typedef struct __attribute__((__packed__)) osu_song_t {
char magic[4]; // 0 - 3
......
#include "util.h"
#ifndef UTIL_H_
#define UTIL_H_
#define ALIGN_16(ptr) (void *)(((uint64_t)(ptr))&(~0x3)+2)
#define ALIGN_32(ptr) (void *)(((uint64_t)(ptr))&(~0xf)+4)
#define ALIGN_64(ptr) (void *)(((uint64_t)(ptr))&(~0xff)+8)
#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