void PowerUpSpawnEffect::render(AbstractConsole *console) { if (mode == 0){ renderMode0(console); } else if (mode == 1){ renderMode1(console); } else if (mode == 2){ renderMode2(console); } }
int main (void) { SP=0xffff; uint16_t shipX =150; tile_a_x=1; tile_b_x=5; setMap(); uint8_t lastTime = 5; uint8_t mode = 0x74; tileMap[100]=0x0001; for (;;) { waitForNewFrame(); //read the mouse location uint16_t mouse_x=PORT_MOUSEX; uint16_t mouse_y=PORT_MOUSEY; uint16_t tile_x = mouse_x / 8; uint16_t tile_y = mouse_y / 8; uint16_t mtile = tile_y*32+tile_x; uint8_t ch = PORT_CONSOLE; switch (ch) { case 'a': translateTilePalette(-1,0); break; case 'd': translateTilePalette(1,0); break; case 'w': translateTilePalette(0,-1); break; case 's': translateTilePalette(0,1); break; case 'z': tileMap[mtile]= (tileMap[mtile] & 0xf0ff) | ((tileMap[mtile] - 0x0100) & 0x0f00); break; case 'x': tileMap[mtile]= (tileMap[mtile] & 0xf0ff) | ((tileMap[mtile] + 0x0100) & 0x0f00) ; } if (ch=='z') { } if (ch=='x') { } uint8_t now = PORT_TIME; uint8_t nextStep = now>lastTime; lastTime=now; if (nextStep) { mode+=1; if (mode > 0x74) mode=0x71; } renderMode1(tileset,tileMap,tileset_palettes,32*2,0,0); blitTilePalette(); //write a grid of rectangles showing the serial pixel output palette for (uint16_t ty=0;ty <4; ty++) { for (uint16_t tx=0;tx <4; tx++) { serial_fillRect(200+tx*6,20+ty*6,5,5,(ty<<2)+tx); } } uint16_t buttons = PORT_BUTTONS; for (uint16_t b=0;b <16; b++) { serial_fillRect(100+b*6,30,5,5,(buttons & (1<<b))?2:1); } if (buttons & 0x2000) { int16_t tile = screen_to_palette_tile(mouse_x,mouse_y); if (tile != -1) { tile_a_x=tile >>8; tile_a_y=tile &0xff; } }