Skip to content

Instantly share code, notes, and snippets.

@danirod
Created August 17, 2013 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danirod/6257761 to your computer and use it in GitHub Desktop.
Save danirod/6257761 to your computer and use it in GitHub Desktop.
Jugando un poco con el GBDK. No me hago responsable de lo que puedas hacer con esto. Necesitas tener instalado el GDBK (Game Boy Developer Kit) - http://gdbk.sourceforge.net
// Jugando un poco con el GBDK.
// Autor: Dani Rodríguez [t:@danirod93]
// No me hago responsable de lo que puedas hacer con esto.
// Necesitas tener instalado el GDBK (Game Boy Developer Kit)
// http://gdbk.sourceforge.net
#include <gb/gb.h>
#include <rand.h>
#include <stdio.h>
// Importante: CADENAS debe contener el número de cadenas en strings[].
// Si añades o eliminas cadenas actualiza el valor de CADENAS o habrá errores.
#define CADENAS 4
const char *strings[CADENAS] = {
"YO TE GOBIERNO",
"ERES MI ESCLAVO",
"HAZ LO QUE TE DIGA",
"ESTAS A MIS ORDENES"
};
#define DELAY_CHR 10 // Milisegundos de delay entre caracter y caracter
#define DELAY_LINE 500 // Milisegundos de delay entre línea y línea
// Valor absoluto de k. Tardo más en buscar si esta función ya está
// dentro de la librería GBDK que en hacerla directamente, la verdad.
static int abs(int k) {
return (k >= 0) ? k : k * -1;
}
int main(void) {
int rnd, i;
char* string;
for(;;) {
// Toma una cadena al azar.
rnd = abs(rand() % CADENAS);
string = strings[rnd];
// Imprime esa cadena caracter a caracter.
for(i = 0; string[i] != NULL; i++) {
printf("%c", string[i]);
delay(DELAY_CHR);
}
// Siguiente línea
printf("\n");
delay(DELAY_LINE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment