diff --git a/CMakeLists.txt b/CMakeLists.txt index da6aa6a..99ec241 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,10 @@ set(ASSETS_cg assets-cg/font.png assets-cg/Sprites/emp_circ.png assets-cg/Sprites/fill_circ.png + + assets-cg/Sprites/fill_circ.png + assets-cg/Sprites/mainship1.png + assets-cg/Sprites/mainship2.png # ... ) diff --git a/assets-cg/Sprites/mainship1.png b/assets-cg/Sprites/mainship1.png new file mode 100644 index 0000000..b62778a Binary files /dev/null and b/assets-cg/Sprites/mainship1.png differ diff --git a/assets-cg/Sprites/mainship2.png b/assets-cg/Sprites/mainship2.png new file mode 100644 index 0000000..bc06414 Binary files /dev/null and b/assets-cg/Sprites/mainship2.png differ diff --git a/capture b/capture index 0332a60..7742334 100755 --- a/capture +++ b/capture @@ -1 +1 @@ -fxlink -iw +fxlink -iw -q diff --git a/src/MyAzurShaders.h b/src/MyAzurShaders.h index 413295a..55e5efe 100644 --- a/src/MyAzurShaders.h +++ b/src/MyAzurShaders.h @@ -10,8 +10,12 @@ void azrp_pixel(int x1, int y1, int color); void azrp_pixellist(std::vector const &list, int fragnum ); +#define SHOW_PIXELS 1 +#define SHOW_STARS 2 + void azrp_starfield( void ); void azrp_starfield_init( uint8_t nbstars ); void azrp_starfield_close( void ); +void azrp_starfield_USBDEBUG( uint8_t info ); #endif //MYAZURSHADERS_H \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index be2c1f4..81cb4fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,48 @@ std::vector MyParticles; Starfield *MyStarField; uint8_t texttodraw=1; +extern bopti_image_t img_mainship1, img_mainship2; +uint8_t movement = -1; +uint16_t playerX = 0; +uint16_t playerY = 0; + +uint16_t bossX = 0; +uint16_t bossY = 0; + + + +static void hook_prefrag(int id, void *fragment, int size) +{ + if(!screenshot && !record) + return; + + /* Screenshot takes precedence */ + char const *type = screenshot ? "image" : "video"; + + int pipe = usb_ff_bulk_output(); + + if(id == 0) { + usb_fxlink_header_t h; + usb_fxlink_image_t sh; + int size = azrp_width * azrp_height * 2; + + usb_fxlink_fill_header(&h, "fxlink", type, size + sizeof sh); + sh.width = htole32(azrp_width); + sh.height = htole32(azrp_height); + sh.pixel_format = htole32(USB_FXLINK_IMAGE_RGB565); + + usb_write_sync(pipe, &h, sizeof h, 4, false); + usb_write_sync(pipe, &sh, sizeof sh, 4, false); + } + + usb_write_sync(pipe, fragment, size, 4, false); + + if(id == azrp_frag_count - 1) { + usb_commit_sync(pipe); + screenshot = false; + } +} /*void Create_Starfield( void ) { @@ -55,7 +96,7 @@ uint8_t texttodraw=1; void Create_Explosion( void ) { - if(MyParticles.size()>=150) return; + if(MyParticles.size()>=1) return; srand(rtc_ticks()); @@ -93,34 +134,125 @@ static void update( float dt ) static void get_inputs( void ) { + uint8_t speed = 4; + key_event_t ev; while((ev = pollevent()).type != KEYEV_NONE) { } + movement = 0; + if(keydown(KEY_SHIFT)) {Create_Explosion();} if(keydown(KEY_EXIT)) {exitToOS = true; }; - if(keydown(KEY_7)) {screenshot = true; }; - if(keydown(KEY_8)) {record = !record; }; - if(keydown(KEY_9)) {textoutput = true; }; + if(keydown(KEY_7)) {screenshot = true;}; + if(keydown(KEY_8)) {record = true; }; + if(keydown(KEY_9)) {record = false; }; + if(keydown(KEY_DEL)) {textoutput = true;}; if(keydown(KEY_F1)) {texttodraw=0;} if(keydown(KEY_F2)) {texttodraw=1;} if(keydown(KEY_F3)) {texttodraw=2;} if(keydown(KEY_F4)) {texttodraw=3;} + + + if(keydown(KEY_LEFT)) + { + if(playerX>speed) + playerX-=speed; + } + if(keydown(KEY_RIGHT)) + { + if(playerXspeed) + playerY-=speed; + } + if(keydown(KEY_DOWN)) + { + if(playerY=2) Azur_draw_text(1,51, ">Total = %.3f ml secs", (float) elapsedTime / 1000.0f ); if (texttodraw>=2) Azur_draw_text(1,61, ">Total = %.0f seconds", (float) elapsedTime ); - if (texttodraw>=3) Azur_draw_text(1,81, "Mem Used : %d", _uram_stats->used_memory ); - if (texttodraw>=3) Azur_draw_text(1,91, "Mem Free : %d", _uram_stats->free_memory ); - if (texttodraw>=3) Azur_draw_text(1,101, "Mem Peak Used : %d", _uram_stats->peak_used_memory ); + if (texttodraw>=3) Azur_draw_text(1,81, "Mem Used : %d", _uram_stats->used_memory + extram_stats->used_memory); + if (texttodraw>=3) Azur_draw_text(1,91, "Mem Free : %d", _uram_stats->free_memory + extram_stats->free_memory); + if (texttodraw>=3) Azur_draw_text(1,101, "Mem Peak Used : %d", _uram_stats->peak_used_memory + extram_stats->peak_used_memory ); if (texttodraw>=3) Azur_draw_text(1,121, "Size of Particles : %d bytes", sizeof(Particle) ); @@ -201,6 +342,11 @@ int main(void) azrp_starfield(); + azrp_image_p8_effect(bossX, bossY, &img_mainship2, IMAGE_VFLIP); + + azrp_image_p8(playerX, playerY, &img_mainship1, DIMAGE_NONE); + + azrp_update(); } @@ -220,27 +366,10 @@ int main(void) elapsedTime = ((float) (time_update+time_render)); - if (screenshot && usb_is_open()) - { - usb_fxlink_screenshot(false); - screenshot = false; - } - - if(record && usb_is_open()) - { - usb_fxlink_videocapture(false); - } - if (textoutput && usb_is_open()) { - char texttosend[1024]; - - /*for(unsigned int i=0; i 30 ) color = 0x526A; // Dark Purple Gray-ish - else if ( age > 25 ) color = 0x71D6; // Red Brown -ish - else if ( age > 20 ) color = 0xF80D; // Dark Red - else if ( age > 15 ) color = 0xFB80; // Red - else if ( age > 10 ) color = 0xFFE0; // Yellow + if ( age > 38 ) color = 0x526A; // Dark Purple Gray-ish + else if ( age > 30 ) color = 0x71D6; // Red Brown -ish + else if ( age > 25 ) color = 0xF80D; // Dark Red + else if ( age > 20 ) color = 0xFB80; // Red + else if ( age > 15 ) color = 0xFFE0; // Yellow else color = 0xFFFF; // White azrp_subimage_p8_dye( px-7, py-7, diff --git a/src/starfieldshader.cpp b/src/starfieldshader.cpp index b02529b..58dc876 100644 --- a/src/starfieldshader.cpp +++ b/src/starfieldshader.cpp @@ -29,7 +29,9 @@ #define ORANGE2 0x8AA7 #define ORANGE3 0xDB83 - +#define WHITE1 0x31A6 +#define WHITE2 0x9CD3 +#define WHITE3 0xFFFF uint8_t AZRP_SHADER_STARFIELD = -1; @@ -64,10 +66,41 @@ void azrp_shader_starfield_configure(void) } +void azrp_starfield_USBDEBUG( uint8_t info ) +{ + char texttosend[1024]; + + int nbpixelcumulated = 0; + + if (info==SHOW_PIXELS) + for(unsigned int i=0; ix, pixels[i]->y, pixels[i]->s, pixels[i]->frag, pixels[i]->c, pixels[i]->off ); + usb_fxlink_text(texttosend, 0); + } + else if (info==SHOW_STARS) + for(unsigned int i=0; in==1 || starfield[i]->n==2) nbpixelcumulated+=4; + else if (starfield[i]->n==3) nbpixelcumulated+=9; + else if (starfield[i]->n==4) nbpixelcumulated+=21; + + sprintf( texttosend, "Star %d : x=%d : y=%d : s=%d : n=%d : t=%d : cumul=%d\n", i, starfield[i]->x, starfield[i]->y, starfield[i]->s, starfield[i]->n, starfield[i]->t, nbpixelcumulated ); + usb_fxlink_text(texttosend, 0); + } +} + + void azrp_starfield_init( uint8_t nbstars ) { - srand(rtc_ticks()); + for(auto&s : starfield) + delete(s); + + starfield.clear(); + + + srand(rtc_ticks()); for(int i=0; in==2) + if (s->n==1 || s->n==2) { ptemp = new particle( s->x, s->y, s->s, col2, s->y/16, s->y&15 ); pixels.push_back( ptemp ); @@ -206,17 +238,12 @@ void azrp_starfield_init( uint8_t nbstars ) ptemp = new particle( s->x+3, s->y+4, s->s, col1, (s->y+4)/16, (s->y+4)&15 ); pixels.push_back( ptemp ); } - else - { - ptemp = new particle( s->x, s->y, s->s, col3, s->y/16, s->y&15 ); - pixels.push_back( ptemp ); - } +// else +// { +// ptemp = new particle( s->x, s->y, s->s, col3, s->y/16, s->y&15 ); +// pixels.push_back( ptemp ); +// } } - - for(auto&s : starfield) - delete(s); - - starfield.clear(); } @@ -274,11 +301,11 @@ void azrp_shader_starfield( void *uniforms, void *comnd, void *fragment ) for(int i=0; inbpixel; i++) { - particle *data = cmd->data[i]; + particle *currentpart = cmd->data[i]; - if (cmd->current_frag == data->frag) + if (cmd->current_frag == currentpart->frag) { - frag[azrp_width * data->off + data->x] = data->c; + frag[azrp_width * currentpart->off + currentpart->x] = currentpart->c; } } cmd->current_frag++;