Enemy::Enemy(int i, s16 x, s16 y, s32 vx, s32 vy) : Sprite(i, SpriteSize_8x8, SpriteColorFormat_Bmp, x, y) { /*u16 enemyData[8 * 8] = { 0,1,0,1,1,0,1,0, 1,1,1,1,1,1,1,1, 0,1,0,1,1,0,1,0, 1,1,1,1,1,1,1,1, 1,1,1,0,0,1,1,1, 0,1,0,1,1,0,1,0, 1,1,1,1,1,1,1,1, 0,1,0,1,1,0,1,0 }; u16 u; for(u = 0 ; u < 8 * 8 ; u++) { if(enemyData[u]) { s_gfx[u] = ARGB16(1,31,0,0); } }*/ dmaFillHalfWords(ARGB16(1,31,0,0), s_gfx, 8*8*2); // Copy player data into sprite gfx // Initialize initial members ( for reset ) s_ix = x; s_iy = y; s_ivx = vx; s_ivy = vy; // Initialize other members s_ax = x; s_ay = y; s_vx = vx; s_vy = vy; nbEnemies++; }
uint16_t Image::GetPixel16( int32_t x, int32_t y ) { if ( this->pixels ) { uint8_t * pix = this->GetPixelPointer( x, y ); if ( pix ) return (uint16_t)ARGB16(pix[3]/128, pix[0], pix[1], pix[2]); } return 0; }
void evaluate(tlmmProgram *prog) { int x; dmaFillHalfWords(0, bgGetGfxPtr(3), 256*192*2); for(x = 0; x < 256; x++) { #define SCALE 16 float v = 192/2 - tlmmGetValue(prog, (float)(x-128)/SCALE)*SCALE; if(v >= 0 && v < 192) bgGetGfxPtr(3)[(int)v * 256 + x] = ARGB16(1, 31, 31, 31); } }
static void D_PrintDevStats(void) { int verts = dsvertices; int tris = dspolygons; ST_DrawMessage(0, 0, ARGB16(31, 0, 31, 0), "Memory: %ikb\n", Z_FreeMemory() >> 10); ST_DrawMessage(0, 8, ARGB16(31, 0, 31, 0), "Static: %ikb\n", Z_TagUsage(PU_STATIC) >> 10); ST_DrawMessage(0, 16, ARGB16(31, 0, 31, 0), "Cache: %ikb\n", Z_TagUsage(PU_CACHE) >> 10); ST_DrawMessage(0, 24, ARGB16(31, 0, 31, 0), "Audio: %ikb\n", Z_TagUsage(PU_AUDIO) >> 10); ST_DrawMessage(0, 32, ARGB16(31, 0, 31, 0), "DMA: %ikb\n", gfxdmasize >> 10); ST_DrawMessage(0, 40, ARGB16(31, 0, 31, 0), "Vram: %ikb\n", Z_FreeVMemory(vramzone) >> 10); ST_DrawMessage(0, 48, ARGB16(31, 0, 31, 0), "Vertex: %i\n", verts); ST_DrawMessage(0, 56, ARGB16(31, 0, 31, 0), "Tris: %i\n", tris); ST_DrawMessage(0, 64, ARGB16(31, 0, 31, 0), "Bsp: %ims\n", bsptic); ST_DrawMessage(0, 72, ARGB16(31, 0, 31, 0), "Draw: %ims\n", rendertic); ST_DrawMessage(0, 80, ARGB16(31, 0, 31, 0), "Game: %ims\n", ptic); }
#include "levelsData.h" Map map0 = {0, 0, 0, 96, 24, ARGB16(1,0,31,31), 0, 0, 0, 0}; Map map1 = {1, 0, 0, 32, 72, ARGB16(1,0,31,31), 0, 0, 0, 0}; void fill_map(Map* map) { // Map map->map = (u16*)malloc(map->length * map->height * sizeof(u16)); char filename[25]; sprintf(filename, "efs:/level%i/map", map->id); FILE* file = fopen(filename, "r"); int currentChar = 0; int n = 0; char c[2]; if(file != NULL) { printf("\x1b[11;11HLoading..."); while(currentChar != EOF) { currentChar = fgetc(file); sprintf(c, "%c", currentChar); if((currentChar != ',') && (currentChar != '\n')) { map->map[n] = (u16)atoi(c); n++; } } fclose(file);
void draw_pixel(fbsurface_t* surface, int x, int y){ if(x <= SCREEN_WIDTH && y <= SCREEN_HEIGHT){ int offset = surface->width*y + x; surface->address[offset] = ARGB16(1, 31, 31, 31); } }
int main(int argc, char** argv) { //three sprites of differing color format MySprite sprites[] = { {0, SpriteSize_32x32, SpriteColorFormat_Bmp, 0, 15, 20, 15}, {0, SpriteSize_32x32, SpriteColorFormat_256Color, -1, 0, 20, 80}, {0, SpriteSize_32x32, SpriteColorFormat_16Color, -1, 1, 20, 136} }; videoSetModeSub(MODE_0_2D); consoleDemoInit(); //initialize the sub sprite engine with 1D mapping 128 byte boundary //and no external palette support oamInit(&oamSub, SpriteMapping_Bmp_1D_128, false); vramSetBankD(VRAM_D_SUB_SPRITE); //allocate some space for the sprite graphics for(int i = 0; i < 3; i++) sprites[i].gfx = oamAllocateGfx(&oamSub, sprites[i].size, sprites[i].format); //ugly positional printf iprintf("\x1b[1;1HDirect Bitmap:"); iprintf("\x1b[9;1H256 color:"); iprintf("\x1b[16;1H16 color:"); //fill bmp sprite with the color red dmaFillHalfWords(ARGB16(1,31,0,0), sprites[0].gfx, 32*32*2); //fill the 256 color sprite with index 1 (2 pixels at a time) dmaFillHalfWords((1<<8)|1, sprites[1].gfx, 32*32); //fill the 16 color sprite with index 1 (4 pixels at a time) dmaFillHalfWords((1<<12)|(1<<8)|(1<<4)|1, sprites[2].gfx, 32*32 / 2); //set index 1 to blue...this will be the 256 color sprite SPRITE_PALETTE_SUB[1] = RGB15(0,31,0); //set index 17 to green...this will be the 16 color sprite SPRITE_PALETTE_SUB[16 + 1] = RGB15(0,0,31); int angle = 0; while(1) { for(int i = 0; i < 3; i++) { oamSet( &oamSub, //sub display i, //oam entry to set sprites[i].x, sprites[i].y, //position 0, //priority sprites[i].paletteAlpha, //palette for 16 color sprite or alpha for bmp sprite sprites[i].size, sprites[i].format, sprites[i].gfx, sprites[i].rotationIndex, true, //double the size of rotated sprites false, //don't hide the sprite false, false, //vflip, hflip false //apply mosaic ); } oamRotateScale(&oamSub, 0, angle, (1 << 8), (1<<8)); angle += 64; swiWaitForVBlank(); //send the updates to the hardware oamUpdate(&oamSub); } return 0; }