| 13 | } |
| 14 | |
| 15 | void draw(SDL_Window* window, SDL_Surface* surface) { |
| 16 | int x, y; |
| 17 | |
| 18 | if (SDL_MUSTLOCK(surface)) { |
| 19 | if (SDL_LockSurface(surface) != 0) |
| 20 | sdlError("SDL_LockSurface"); |
| 21 | } |
| 22 | |
| 23 | for (y = 0; y < 256; y++) { |
| 24 | Uint32* p = (Uint32*)(((Uint8*)surface->pixels) + surface->pitch * y); |
| 25 | for (x = 0; x < 256; x++) { |
| 26 | *(p++) = SDL_MapRGB(surface->format, x, x ^ y, y); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | if (SDL_MUSTLOCK(surface)) |
| 31 | SDL_UnlockSurface(surface); |
| 32 | if (SDL_UpdateWindowSurface(window) != 0) |
| 33 | sdlError("SDL_UpdateWindowSurface"); |
| 34 | } |
| 35 | |
| 36 | void verify(void) { |
| 37 | int res = EM_ASM_INT({ |