por supuesto, lo que haga falta
esto sucede en consola
******@******-HP-Pavilion-dv6-Notebook-PC:~/Proyectos/Chip8/src/Chip8$ ls
main.c
******@******-HP-Pavilion-dv6-Notebook-PC:~/Proyectos/Chip8/src/Chip8$ gcc -o main main.c -lSDL2 -lSDL2main
******@******-HP-Pavilion-dv6-Notebook-PC:~/Proyectos/Chip8/src/Chip8$ ls
main main.c
******@******-HP-Pavilion-dv6-Notebook-PC:~/Proyectos/Chip8/src/Chip8$ ./main
No se ha encontrado el archivo******@******-HP-Pavilion-dv6-Notebook-PC:~/Proyectos/Chip8/src/Chip8$
El codigo, las librerias y la parte del main que es donde utilizo las librerias de SDL2
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <SDL2/SDL.h>
int main(int argc, char* argv[]){
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* texture;
SDL_Surface* surface;
SDL_Event event;
int quit = 0;
int last_stick = 0;
int ciclos = 0;
struct machine mac;
srand(time(NULL));
init_machine(&mac);
load_room(&mac);
SDL_Init(SDL_INIT_EVERYTHING);
window = SDL_CreateWindow("CHIP8 EMULATOR",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640, 320,
SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_STREAMING, 64, 32);
surface = SDL_CreateRGBSurface(0, 64, 32, 32,
0x00FF0000,
0x0000FF00,
0x000000FF,
0xFF000000);
SDL_LockTexture(texture, NULL, &surface->pixels, &surface->pitch);
expandir(mac.screen, (Uint32 *)surface->pixels);
SDL_UnlockTexture(texture);
while(!quit){
while(SDL_PollEvent(&event)){
switch(event.type){
case SDL_QUIT:
quit = 1;
break;
}
}
if(SDL_GetTicks() - ciclos > 1){
run_cpu(&mac);
ciclos = SDL_GetTicks();
}
if(SDL_GetTicks() - last_stick > (1000/60)){
if(mac.dt) mac.dt--;
if(mac.st) mac.st--;
SDL_LockTexture(texture, NULL, &surface->pixels, &surface->pitch);
expandir(mac.screen, (Uint32 *)surface->pixels);
SDL_UnlockTexture(texture);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
last_stick = SDL_GetTicks();
}
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}