add capture features + player + fake boss
This commit is contained in:
parent
52c18741bd
commit
2c4ae5619c
|
@ -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
|
||||
# ...
|
||||
)
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -10,8 +10,12 @@ void azrp_pixel(int x1, int y1, int color);
|
|||
void azrp_pixellist(std::vector<Pixel*> 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
|
192
src/main.cpp
192
src/main.cpp
|
@ -46,7 +46,48 @@ std::vector<Particle*> 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(playerX<azrp_width-img_mainship1.width-speed)
|
||||
playerX+=speed;
|
||||
}
|
||||
if(keydown(KEY_UP))
|
||||
{
|
||||
if(playerY>speed)
|
||||
playerY-=speed;
|
||||
}
|
||||
if(keydown(KEY_DOWN))
|
||||
{
|
||||
if(playerY<azrp_height-img_mainship1.height-speed)
|
||||
playerY+=speed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(keydown(KEY_F6))
|
||||
{
|
||||
azrp_starfield_close( );
|
||||
azrp_starfield_init( 200 );
|
||||
azrp_starfield_init( 100 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static kmalloc_arena_t extended_ram = { 0 };
|
||||
|
||||
|
||||
|
||||
bool AddMoreRAM( void )
|
||||
{
|
||||
/* allow more RAM */
|
||||
char const *osv = (char*) 0x80020020;
|
||||
|
||||
if((!strncmp(osv, "03.", 3) && osv[3] <= '6') && gint[HWCALC] == HWCALC_FXCG50) // CG-50
|
||||
{
|
||||
extended_ram.name = "extram";
|
||||
extended_ram.is_default = true;
|
||||
extended_ram.start = (void *)0x8c200000;
|
||||
extended_ram.end = (void *)0x8c500000 ;
|
||||
|
||||
kmalloc_init_arena(&extended_ram, true);
|
||||
kmalloc_add_arena(&extended_ram );
|
||||
return true;
|
||||
}
|
||||
else if (gint[HWCALC] == HWCALC_PRIZM) // CG-10/20
|
||||
{
|
||||
|
||||
extended_ram.name = "extram";
|
||||
extended_ram.is_default = true;
|
||||
|
||||
uint16_t *vram1, *vram2;
|
||||
dgetvram(&vram1, &vram2);
|
||||
dsetvram(vram1, vram1);
|
||||
|
||||
extended_ram.start = vram2;
|
||||
extended_ram.end = (char *)vram2 + 396*224*2;
|
||||
|
||||
kmalloc_init_arena(&extended_ram, true);
|
||||
kmalloc_add_arena(&extended_ram );
|
||||
return false;
|
||||
|
||||
}
|
||||
else if (gint[HWCALC] == HWCALC_FXCG_MANAGER) // CG-50 EMULATOR
|
||||
{
|
||||
|
||||
extended_ram.name = "extram";
|
||||
extended_ram.is_default = true;
|
||||
extended_ram.start = (void *)0x88200000;
|
||||
extended_ram.end = (void *)0x88500000 ;
|
||||
|
||||
kmalloc_init_arena(&extended_ram, true);
|
||||
kmalloc_add_arena(&extended_ram );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FreeMoreRAM( void )
|
||||
{
|
||||
memset(extended_ram.start, 0, (char *)extended_ram.end - (char *)extended_ram.start);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
exitToOS = false;
|
||||
|
@ -128,6 +260,9 @@ int main(void)
|
|||
|
||||
kmalloc_arena_t *_uram = kmalloc_get_arena("_uram");
|
||||
kmalloc_gint_stats_t *_uram_stats;
|
||||
kmalloc_gint_stats_t *extram_stats;
|
||||
|
||||
bool canWeAllocate3Mb = AddMoreRAM();
|
||||
|
||||
__printf_enable_fp();
|
||||
__printf_enable_fixed();
|
||||
|
@ -137,10 +272,15 @@ int main(void)
|
|||
azrp_shader_image_rgb16_configure();
|
||||
azrp_shader_image_p8_configure();
|
||||
azrp_shader_image_p4_configure();
|
||||
azrp_shader_triangle_configure();
|
||||
azrp_hook_set_prefrag(hook_prefrag);
|
||||
|
||||
azrp_starfield_init( 200 );
|
||||
azrp_starfield_init( 100 );
|
||||
|
||||
playerX = (azrp_width - img_mainship1.width)/2;
|
||||
playerY = azrp_height - img_mainship1.height;
|
||||
|
||||
bossX = (azrp_width - img_mainship2.width)/2;
|
||||
bossY = 0;
|
||||
|
||||
usb_interface_t const *interfaces[] = { &usb_ff_bulk, NULL };
|
||||
usb_open(interfaces, GINT_CALL_NULL);
|
||||
|
@ -164,7 +304,8 @@ int main(void)
|
|||
update( elapsedTime );
|
||||
|
||||
// update the RAM consumption status
|
||||
_uram_stats = kmalloc_get_gint_stats(_uram);
|
||||
_uram_stats = kmalloc_get_gint_stats(_uram);
|
||||
extram_stats = kmalloc_get_gint_stats(&extended_ram);
|
||||
}
|
||||
|
||||
prof_leave(perf_update);
|
||||
|
@ -186,9 +327,9 @@ int main(void)
|
|||
if (texttodraw>=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<NBPARTS; i++)
|
||||
{
|
||||
sprintf( texttosend, "Star %d : x=%d : y=%d : f=%d : s=%d : c=%d", i, datastar[i].x, datastar[i].y, datastar[i].s, datastar[i].frag, datastar[i].c );
|
||||
usb_fxlink_text(texttosend, 0);
|
||||
}*/
|
||||
|
||||
azrp_starfield_USBDEBUG( SHOW_PIXELS );
|
||||
azrp_starfield_USBDEBUG( SHOW_STARS );
|
||||
textoutput = false;
|
||||
}
|
||||
}
|
||||
|
@ -257,5 +386,8 @@ int main(void)
|
|||
prof_quit();
|
||||
usb_close();
|
||||
|
||||
|
||||
FreeMoreRAM( );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ Particle::Particle( uint16_t lx, uint16_t ly )
|
|||
sy = (libnum::num( rand() % 11 - 5 )) / 4;
|
||||
|
||||
age = libnum::num( rand() % 3 );
|
||||
maxage = libnum::num( 20 + ( rand() % 20 ) );
|
||||
maxage = libnum::num( 30 + ( rand() % 20 ) );
|
||||
|
||||
size = libnum::num( 3 + ( rand() % 5 ) );
|
||||
|
||||
|
@ -57,11 +57,11 @@ void Particle::Render( )
|
|||
|
||||
int color;
|
||||
|
||||
if ( age > 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,
|
||||
|
|
|
@ -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; i<pixels.size(); i++)
|
||||
{
|
||||
sprintf( texttosend, "Pixel %d : x=%d : y=%d : s=%d : f=%d : c=%d : o=%d\n", i, pixels[i]->x, 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; i<starfield.size(); i++)
|
||||
{
|
||||
if (starfield[i]->n==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; i<nbstars; i++)
|
||||
|
@ -112,17 +145,16 @@ void azrp_starfield_init( uint8_t nbstars )
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
col1 = 0xFFFF;
|
||||
col2 = 0XFFFF;
|
||||
col3 = 0XFFFF;
|
||||
col1 = WHITE1;
|
||||
col2 = WHITE2;
|
||||
col3 = WHITE3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
particle *ptemp;
|
||||
|
||||
if (s->n==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; i<cmd->nbpixel; 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++;
|
||||
|
|
Loading…
Reference in New Issue