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

cleanup

parent f3a56457
No related branches found
No related tags found
No related merge requests found
...@@ -171,6 +171,7 @@ int main() { ...@@ -171,6 +171,7 @@ int main() {
goto PROBE; goto PROBE;
IMG: IMG:
printf("Trying to cache %x (%dx%d) into %x...\n", mpeg_img_addr, mpeg_img_width, mpeg_img_height, mpeg_img_dest);
temp_dest = mpeg_img_dest; temp_dest = mpeg_img_dest;
bg_ptr = mpeg_img_addr; bg_ptr = mpeg_img_addr;
bptr = 256; bptr = 256;
......
#ifndef GL_H_ #ifndef GL_H_
#define GL_H_ #define GL_H_
#include "painters.h"
#include "util.h"
#include "regs.h" #include "regs.h"
#include "util.h"
#include "painters.h"
#include "font.h"
#define GL_CMD_NOOP 0x0 #define GL_CMD_NOOP 0x0
#define GL_CMD_RECT 0x1 #define GL_CMD_RECT 0x1
......
...@@ -11,6 +11,8 @@ void gl_circle(uint16_t x0, uint16_t y0, uint16_t r, ...@@ -11,6 +11,8 @@ void gl_circle(uint16_t x0, uint16_t y0, uint16_t r,
uint16_t color0, uint16_t color1, uint16_t stroke, uint16_t color0, uint16_t color1, uint16_t stroke,
uint8_t gradient_direction); uint8_t gradient_direction);
void gl_ring(uint16_t x0, uint16_t y0, uint16_t r, uint16_t w, uint16_t stroke);
void gl_polygon(uint16_t x_top, uint16_t y_top, void gl_polygon(uint16_t x_top, uint16_t y_top,
uint16_t x_bot, uint16_t y_bot, uint16_t x_bot, uint16_t y_bot,
uint16_t x_left, uint16_t y_left, uint16_t x_left, uint16_t y_left,
......
#include"osu_process.h"
int main(){
//initialization
osu_session global;
osu_init(&global);
//Title Page
title_process(&global);
//Selection Page
song_select_process(&global);
//song play, scoring also handled
song_play_process(&global);
//
song_score_process(&global);
}
\ No newline at end of file
#include "osu_draw.h"
void osu_draw_frame(osu_session* global){
//wait until vertical sync
gl_finalize_wait();
uint8_t temp_queue_end;
char object_label;
//void* temp_p;
while(temp_queue_end!=(global->draw_queue_start)){
object_label = *((char*)((global->draw_dynamic_queue)[temp_queue_end]));
switch (object_label){
case 'h': // hit circle
osu_draw_hit_circle((global->draw_dynamic_queue)[temp_queue_end],global->current_time);
break;
case 's':
osu_draw_spin(draw_dynamic_queue[temp_queue_end]);
break;
/* case 'l': // slider
osu_draw_slider(draw_dynamic_queue[temp_queue_end]);
break;
*/
}
--temp_queue_end;
temp_queue_end &= DRAW_QUEUE_SIZE_MODE;
}
//hard draw part
gl_finalize_frame();
}
void osu_draw_hit_circle(elem_hit_circle* circle,clock_t current_time){
if (current_time<check_timing){
gl_ring(
circle->x,
circle->y,
circle->approach_radius,
4,
circle->gradient_color1
);
gl_circle(
circle->x,
circle->y,
circle->hit_radius,
circle->gradient_color1,
circle->gradient_color2,
circle->stroke_color,
circle->gradient_direction
);
gl_ring(
circle->x,
circle->y,
circle->hit_radius,
3,
0xFFFFFFFF
);
circle->approach_radius -= circle->approach_rate;
} else if (current_time < end_timing){
gl_circle(
circle->x,
circle->y,
circle->hit_radius,
circle->gradient_color1,
circle->gradient_color2,
circle->stroke_color,
circle->gradient_direction
);
}
}
\ No newline at end of file
#ifndef OSU_DRAW_H_
#define OSU_DRAW_H_
#include <inttypes>
#include "osu_process.h"
#include "osu_object_includes.h"
osu_draw_frame();
#endif
\ No newline at end of file
#ifndef OSU_OBJECT_INCLUDES_H_
#define OSU_OBJECT_INCLUDES_H_
#include<inttypes>
typedef struct __attribute__((__packed__)) hit_circle_t{
//32 Byte
char type,
uint_16t x,y,
uint_32t start_timing,
uint_32t check_timing,
uint_32t disappear_timing,
//uint_32t end_timing,
uint_16t hit_radius,
uint_16t approach_radius,
uint_16t gradient_color1,
uint_16t gradient_color2,
uint_16t stroke_color,
uint_8t gradient_direction,
uint_32t reserved
}elem_hit_circle;
typedef struct __attribute__((__packed__)) hit_circle_t{
//32 Byte
char type,
uint_16t x,y,
uint_32t start_timing,
uint_32t disappear_timing,
uint_16t radius,
uint_16t gradient_color1,
uint_16t gradient_color2,
uint_16t stroke_color,
uint_8t gradient_direction,
char padding[10]
}elem_spinner;
/*typedef struct __attribute__((__packed__)) rect_slider_t{
char type;
uint_32t start_timing,
uint_32t check_timing,
uint_32t disappear_timing,
//uint_32t end_timing,
uint_16t hit_radius,
uint_16t approach_radius,
uint_16t x1,y1,x2,y2,x3,y3,x4,y4,
uint_8t gradient_direction,
uint_32t reserved
}elem_rect_slider;*/
#endif
\ No newline at end of file
#include "osu_process.h"
void init_process(osu_session* global){
global->draw_queue = malloc(sizeof(void*)*DRAW_QUEUE_SIZE);
global->buff = malloc(512);
global->play_timeline = malloc(65536);
//set to nearest 32 address
mpeg_read(0,1,global->buff);
global->total_song_count = ((osu_meta*)global->buff) -> songs;
}
void loading_process(osu_session* global){
uint32_t i;
//scene start TBD
//send loading command to sd-card core
mpeg_read(global->song_number,1,&(global->playing_song));
mpeg_set_bg(global->playing_song.cover_begin);
//beat map reading
mpeg_read(
global->playing_song.beatmap_begin,
global->playing_song.beatmap_len,
*(global->play_timeline));
//beat map parsing
uint32_t* p_temp = *(global->play_timeline);
if ((*p_temp)!= 0b01110010011001010110000101101100){
printf("parsing magic failed!");
return;
}
++p_temp;
global->play_timeline_count = *((uint32_t*)p_temp);
global->play_timeline = malloc(4*(global->play_timeline_count));
//locate the real data address
++p_temp;
for (i=0;i<global->play_timeline_count;++i){
global->play_timeline[i] = p_temp;
//jump 32 bytes
p_temp =((void*)p_temp + ELEMENT_LENGTH);
}
}
/*void title_process(){
scene_start();
//timing
clock_t start_time= clock();
//send loading command to sd-card core
clock_t current_time;
//loop start
while(1){
//get current time
current_time = clock()-start_time;
//check mouse press
//specify the title elements
//draw the frame
osu_draw_frame();
}
//end handle
scene_end();
}*/
void play_process(osu_session* global){
//scene_start(global);
//timing
clock_t start_time= clock();
//send loading command to sd-card core
global->play_timeline_start = 0;
//loop start
while(1){
//get current time
current_time = clock()-start_time;
if (global->current_time > (global->playing_song.play_time)) break;
//update the drawing elements first
osu_draw_queue_update(global);
//then get keyboard/mouse input and handle
//HInput();
//draw the frame
osu_draw_frame(global);
}
//end handle
scene_end(global);
}
void osu_draw_queue_update(osu_session* global){
//clear existing elements
queue_temp_start = global->draw_dynamic_queue_start;
elem_hit_circle* element_temp_p = (global->draw_dynamic_queue)[queue_temp_start];
while (queue_temp_start!=global->draw_dynamic_queue_end){
if (global->current_time >= (element_temp_p->disappear_timing)){
//pop draw element from front
(global->draw_dynamic_queue)[queue_temp_start] = NULL;
++(global->draw_dynamic_queue_start);
} else break;
++temp_queue_start;
temp_queue_start &= DRAW_QUEUE_SIZE_MODE;
element_temp_p = (global->draw_dynamic_queue)[queue_temp_start];
}
//add new element
if (global->play_timeline_start>=global->play_timeline_count) return;
elem_hit_circle* element_temp_p=(global->play_timeline)[play_timeline_start];
while(global->play_timeline_start<global->play_timeline_count){
if ((element_temp_p->start_timing)<= global->current_time){
//add draw element at queue end
++(global->draw_dynamic_queue_end);
global->draw_dynamic_queue_end &= DRAW_QUEUE_SIZE_MODE;
(global->draw_dynamic_queue)[global->draw_dynamic_queue_end] = (void*)element_temp_p;
} else break;
++(global->play_timeline_start);
element_temp_p=(global->play_timeline)[global->play_timeline_start];
}
}
void scene_end(osu_session* global){
//clear the global draw queue
int i;
for (i=0;i<DRAW_QUEUE_SIZE;++i){
(global->draw_queue)[i] = NULL;
}
//dim the background
for (i=0;i<128;i+=4){
gl_background_dim(i);
osu_draw_frame();
}
global->draw_dynamic_queue_start=0;
global->draw_dynamic_queue_end=0;
}
/*
void scene_start(){
//show the background
}*/
/*void HInput(){
get_mouse_input();
if (mouse_left_click){
//check if it hits anything
}
}*/
#ifndef OSU_PROCESS_H
#define OSU_PROCESS_H
#include"../interprocess/interprocess.h"
#include"osu_draw.h"
#include "osufs.h"
#define DRAW_QUEUE_SIZE 128
#define DRAW_QUEUE_SIZE_MOD 0b01111111
//counted by 4 bytes a time
#define ELEMENT_LENGTH 32
//#define PLAY_TIMELINE_START
//declare the global
typedef struct osu_t{
void** draw_dynamic_queue,
void** play_timeline, //= PLAY_TIMELINE_START,
uint8_t draw_dynamic_queue_start,
uint8_t draw_dynamic_queue_end,
uint32_t play_timeline_start,
uint32_t play_timeline_count,
void** draw_hard_list,
uint32_t current_time,
uint16_t total_song_count,
void* buff,
uint16_t song_number,
osu_song playing_song
}osu_session;
void title_process(){
//
}
void loading_process();
#endif
\ No newline at end of file
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