static int DrvDraw() { #define sw(n) ((nColor >> n) & 1 ? 0xff : 0) #define color() BurnHighCol(pen >> 16, pen >> 8, pen, 0) unsigned int back_pen = (sw(3) << 16) | (sw(4) << 8) | sw(5); unsigned int fore_pen = (sw(0) << 16) | (sw(1) << 8) | sw(2); for (int offs = 0; offs < 0x0600; offs++) { unsigned char x = offs << 4; unsigned char y = offs >> 4 << 1; unsigned char data = Mem[0x4000 + offs]; for (int i = 0; i < 8; i++) { unsigned int pen = (data & 0x80) ? fore_pen : back_pen; PutPix(pBurnDraw + (x + 0 + (y + 0) * 256) * nBurnBpp, color()); PutPix(pBurnDraw + (x + 1 + (y + 0) * 256) * nBurnBpp, color()); PutPix(pBurnDraw + (x + 0 + (y + 1) * 256) * nBurnBpp, color()); PutPix(pBurnDraw + (x + 1 + (y + 1) * 256) * nBurnBpp, color()); x = x + 2; data = data << 1; } } return 0; }
//移动 void Move() { switch (snake.dir) { case LEFT: PutPix(BACK, snake.tail.x, snake.tail.y); //清除尾部 UpTail(); //更新尾部 PutPix(LEFT, snake.head.x-1, snake.head.y); //填充头部 stat[snake.head.x][snake.head.y] = LEFT; //更新头部 snake.head.x--; break; case UP: PutPix(BACK, snake.tail.x, snake.tail.y); //清除尾部 UpTail(); //更新尾部 PutPix(LEFT, snake.head.x, snake.head.y-1); //填充头部 stat[snake.head.x][snake.head.y] = UP; //更新头部 snake.head.y--; break; case RIGHT: PutPix(BACK, snake.tail.x, snake.tail.y); //清除尾部 UpTail(); //更新尾部 PutPix(LEFT, snake.head.x+1, snake.head.y); //填充头部 stat[snake.head.x][snake.head.y] = RIGHT; //更新头部 snake.head.x++; break; case DOWN: PutPix(BACK, snake.tail.x, snake.tail.y); //清除尾部 UpTail(); //更新尾部 PutPix(LEFT, snake.head.x, snake.head.y+1); //填充头部 stat[snake.head.x][snake.head.y] = DOWN; //更新头部 snake.head.y++; break; } }
static void rallybik_draw_sprites(int priority) { unsigned short *sprite = (unsigned short*)FCU2RAM; for (int offs = 0; offs < (0x1000/2); offs += 4) { int attrib = sprite[offs + 1]; if ((attrib & 0x0c00) == priority) { int sy = (sprite[offs + 3] >> 7) & 0x1ff; if (sy != 0x0100) { int code = sprite[offs] & 0x7ff; int color = attrib & 0x3f; int sx = (sprite[offs + 2] >> 7) & 0x1ff; int flipx = attrib & 0x100; int flipy = attrib & 0x200; if (flipx) sx -= 15; sx -= 31; sy -= 16; if (sy < -15 || sx < -15 || sy >= 240 || sx >= 320) continue; { int flip = 0; if (flipx) flip |= 0x0f; if (flipy) flip |= 0xf0; unsigned char *gfx = FCU2ROM + (code * 0x100); pTilePalette = &ToaPalette2[color << 4]; for (int y = 0; y < 16; y++, sy++) { if (sy < 0 || sy >= 240) continue; for (int x = 0; x < 16; x++, sx++) { if (sx < 0 || sx >= 320) continue; int pxl = gfx[((y * 16) + x) ^ flip]; if (pxl) { PutPix(pBurnDraw + ((sy * 320) + sx) * nBurnBpp, pTilePalette[pxl]); } } sx -= 16; } } } }