diff --git a/makefile b/makefile new file mode 100644 index 0000000..b2da6de --- /dev/null +++ b/makefile @@ -0,0 +1,16 @@ +CC := gcc +CFLAGS := -Wall +LINKER_FLAGS = `sdl2-config --cflags --libs` -lxmp -lSDL2_image + +test: + make clean + make build + +build: + $(CC) $(CFLAGS) -o presentator presentator.c $(LINKER_FLAGS) + +run: + ./presentator + +clean: + -rm presentator diff --git a/mods/001.mod b/mods/001.mod new file mode 100644 index 0000000..4000476 Binary files /dev/null and b/mods/001.mod differ diff --git a/mods/002.mod b/mods/002.mod new file mode 100644 index 0000000..603a8b5 Binary files /dev/null and b/mods/002.mod differ diff --git a/mods/003.xm b/mods/003.xm new file mode 100644 index 0000000..5508f8a Binary files /dev/null and b/mods/003.xm differ diff --git a/mods/004.xm b/mods/004.xm new file mode 100644 index 0000000..5775ec3 Binary files /dev/null and b/mods/004.xm differ diff --git a/mods/005.mod b/mods/005.mod new file mode 100644 index 0000000..779f32b Binary files /dev/null and b/mods/005.mod differ diff --git a/mods/006.mod b/mods/006.mod new file mode 100644 index 0000000..0fc793c Binary files /dev/null and b/mods/006.mod differ diff --git a/mods/007.mod b/mods/007.mod new file mode 100644 index 0000000..e0a68bb Binary files /dev/null and b/mods/007.mod differ diff --git a/mods/008.mod b/mods/008.mod new file mode 100644 index 0000000..6e645af Binary files /dev/null and b/mods/008.mod differ diff --git a/mods/009.mod b/mods/009.mod new file mode 100644 index 0000000..04ae030 Binary files /dev/null and b/mods/009.mod differ diff --git a/mods/crack.xm b/mods/crack.xm new file mode 100644 index 0000000..a13b3a0 Binary files /dev/null and b/mods/crack.xm differ diff --git a/presentator b/presentator new file mode 100755 index 0000000..2c6cd33 Binary files /dev/null and b/presentator differ diff --git a/presentator.c b/presentator.c new file mode 100644 index 0000000..4323089 --- /dev/null +++ b/presentator.c @@ -0,0 +1,198 @@ +#include +#include +#include +#include +#include + +// Fanta 2026 +// Presentator 0.1 + +// Variables +int modPlaying; +char * modName = NULL; +int modVolume = 100; +int iv; +char *imgVol[] = {"res/vol100.png","res/vol090.png","res/vol080.png","res/vol070.png","res/vol060.png","res/vol050.png","res/vol040.png","res/vol030.png","res/vol020.png","res/vol010.png","res/vol000.png"}; +char windowTitle[16] = "Presentator 0.1"; +int windowWidth = 1024; +int windowHeight = 768; +char * slidesIndex = "slides/index.txt"; +char * actualSlide = NULL; +int actualNSlide = 1; +bool quit = false; +SDL_Window * window; +SDL_Renderer * render; +SDL_Texture *textureVolume = NULL; +SDL_Texture *textureSlide = NULL; +SDL_Event evento; +xmp_context ctx; + +// Functions +int createWindow(void){ + SDL_Init(SDL_INIT_VIDEO); + window = SDL_CreateWindow(windowTitle,SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,windowWidth,windowHeight,SDL_WINDOW_FULLSCREEN); + render = SDL_CreateRenderer(window, -1, 0); + return 0; +} + +int refreshVolumeArea(int iv){ + SDL_Rect textureVolumeRect1 = { 0, 0, 398, 68 }; + SDL_Rect textureVolumeRect2 = { 910, 20, 100, 20 }; + IMG_Init(IMG_INIT_PNG); + textureVolume = IMG_LoadTexture(render, imgVol[iv]); + SDL_RenderCopy(render, textureVolume, &textureVolumeRect1, &textureVolumeRect2); + return 0; +} + +static void playBuffer(void *udata, Uint8 *stream, int len) +{ + if (xmp_play_buffer((xmp_context)udata, stream, len, 0) < 0){ modPlaying = 0; } +} + +static int initAudio(xmp_context ctx) { + SDL_AudioSpec a; + a.freq = 44100; + a.format = AUDIO_S16; + a.channels = 2; + a.samples = 2048; + a.callback = playBuffer; + a.userdata = ctx; + if (SDL_OpenAudio(&a, NULL) < 0) { printf("error inicializando audio: %s\n", SDL_GetError()); return 1; } + return 0; +} + +void loadMod(char *modPath){ + modName = modPath; + ctx = xmp_create_context(); + xmp_load_module(ctx, modName); + xmp_start_player(ctx, 44100, 0); + xmp_set_player(ctx, XMP_PLAYER_VOLUME, modVolume); + initAudio(ctx); + modPlaying = 1; + SDL_PauseAudio(0); +} + +int stopMod(void){ + xmp_end_player(ctx); + xmp_free_context(ctx); + SDL_CloseAudio(); + return 0; +} + +int loadSlide(int nslide){ + FILE * fp; + char * line = NULL; + size_t len = 0; + int nline = 1; + ssize_t read; + + fp = fopen(slidesIndex, "r"); + while ((read = getline(&line, &len, fp)) != -1) { + if (nslide == nline){ + actualSlide = line; + actualSlide[ strlen(actualSlide) - 1 ] = '\0'; + SDL_Rect textureSlideRect = { 0, 0, windowWidth, windowHeight }; + IMG_Init(IMG_INIT_PNG); + textureSlide = IMG_LoadTexture(render, actualSlide); + SDL_RenderCopy(render, textureSlide, NULL, &textureSlideRect); + } + nline = nline +1; + } + fclose(fp); + if (line){ free(line); }; + return 0; +} + +int renderAll(void){ + loadSlide(actualNSlide); + refreshVolumeArea(iv); + SDL_RenderPresent(render); + return 0; +} + +// Main +int main(int argc, char ** argv) { + createWindow(); + loadMod("mods/001.mod"); + loadSlide(1); + refreshVolumeArea(0); + SDL_RenderPresent(render); + + while (!quit) { + SDL_WaitEvent(&evento); + + switch (evento.type) { + case SDL_KEYDOWN: + switch (evento.key.keysym.sym) { + case SDLK_q: + stopMod(); + quit = true; + break; + case SDLK_DOWN: + if(modVolume > 0) { + modVolume = modVolume - 10; + xmp_set_player(ctx, XMP_PLAYER_VOLUME, modVolume); + iv = iv + 1; + renderAll(); + } + break; + case SDLK_UP: + if(modVolume < 100) { + modVolume = modVolume + 10; + xmp_set_player(ctx, XMP_PLAYER_VOLUME, modVolume); + iv = iv - 1; + renderAll(); + } + break; + case SDLK_1: + stopMod(); + loadMod("mods/001.mod"); + break; + case SDLK_2: + stopMod(); + loadMod("mods/002.mod"); + break; + case SDLK_3: + stopMod(); + loadMod("mods/003.xm"); + break; + case SDLK_4: + stopMod(); + loadMod("mods/004.xm"); + break; + case SDLK_5: + stopMod(); + loadMod("mods/005.mod"); + break; + case SDLK_6: + stopMod(); + loadMod("mods/006.mod"); + break; + case SDLK_7: + stopMod(); + loadMod("mods/007.mod"); + break; + case SDLK_8: + stopMod(); + loadMod("mods/008.mod"); + break; + case SDLK_9: + stopMod(); + loadMod("mods/009.mod"); + break; + case SDLK_RIGHT: + actualNSlide = actualNSlide + 1; + renderAll(); + break; + case SDLK_LEFT: + actualNSlide = actualNSlide - 1; + renderAll(); + break; + } + break; + } + + + } + +} diff --git a/res/vol000.png b/res/vol000.png new file mode 100644 index 0000000..d648520 Binary files /dev/null and b/res/vol000.png differ diff --git a/res/vol010.png b/res/vol010.png new file mode 100644 index 0000000..af7c685 Binary files /dev/null and b/res/vol010.png differ diff --git a/res/vol020.png b/res/vol020.png new file mode 100644 index 0000000..6b9d3d6 Binary files /dev/null and b/res/vol020.png differ diff --git a/res/vol030.png b/res/vol030.png new file mode 100644 index 0000000..3e88b65 Binary files /dev/null and b/res/vol030.png differ diff --git a/res/vol040.png b/res/vol040.png new file mode 100644 index 0000000..77474cc Binary files /dev/null and b/res/vol040.png differ diff --git a/res/vol050.png b/res/vol050.png new file mode 100644 index 0000000..13a688f Binary files /dev/null and b/res/vol050.png differ diff --git a/res/vol060.png b/res/vol060.png new file mode 100644 index 0000000..0adef2e Binary files /dev/null and b/res/vol060.png differ diff --git a/res/vol070.png b/res/vol070.png new file mode 100644 index 0000000..361cc20 Binary files /dev/null and b/res/vol070.png differ diff --git a/res/vol080.png b/res/vol080.png new file mode 100644 index 0000000..f1c84b9 Binary files /dev/null and b/res/vol080.png differ diff --git a/res/vol090.png b/res/vol090.png new file mode 100644 index 0000000..978f277 Binary files /dev/null and b/res/vol090.png differ diff --git a/res/vol100.png b/res/vol100.png new file mode 100644 index 0000000..f766af9 Binary files /dev/null and b/res/vol100.png differ diff --git a/slides/001.png b/slides/001.png new file mode 100644 index 0000000..bb3c249 Binary files /dev/null and b/slides/001.png differ diff --git a/slides/002.png b/slides/002.png new file mode 100644 index 0000000..7519ab3 Binary files /dev/null and b/slides/002.png differ diff --git a/slides/003.png b/slides/003.png new file mode 100644 index 0000000..7cb693a Binary files /dev/null and b/slides/003.png differ diff --git a/slides/004.png b/slides/004.png new file mode 100644 index 0000000..d96c5d4 Binary files /dev/null and b/slides/004.png differ diff --git a/slides/index.txt b/slides/index.txt new file mode 100644 index 0000000..3f8c2e9 --- /dev/null +++ b/slides/index.txt @@ -0,0 +1,4 @@ +slides/001.png +slides/002.png +slides/003.png +slides/004.png diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..a0dc896 --- /dev/null +++ b/todo.txt @@ -0,0 +1,4 @@ +- Añadir opción para abrir en ventana como parametro. +window = SDL_CreateWindow(windowTitle,SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,windowWidth,windowHeight,SDL_WINDOW_OPENGL); + +