1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/// fondos.c
/*---------------------------------------------------------------------------------
Este codigo se ha implementado basandose en el ejemplo "Simple sprite demo" de 
dovoto y otro de Jaeden Amero
---------------------------------------------------------------------------------*/

#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "fondos.h"

/* añadir aqui los includes para cada fondo. */

#include "Fondo.h"

/* Seleccionar un canal DMA para copiar a memoria las imagenes */
static const int DMA_CHANNEL = 3;

/* Procedimiento para configurar el sistema de fondos. */
void initFondos() {
    /*  Establecer la afinidad del fondo 3 de la pantalla principal con color de 16 bits. */
    REG_BG3CNT = BG_BMP16_256x256 |
                 BG_BMP_BASE(0) | // La direccion inicial de memoria
                 BG_PRIORITY(3); // Baja prioridad

    /*  Establecer la matriz de transformacion afin del fondo 3 de la pantalla principal
        a la matriz de identidad. */
    REG_BG3PA = 1 << 8;
    REG_BG3PB = 0;
    REG_BG3PC = 0;
    REG_BG3PD = 1 << 8;

/*******************************************************************************************/
    /*  Definir la situacion del fondo 3 de la pantalla principal. */
    /*  Esto debera cambiar segun la posicion en la que se quiera poner el grafico */
    REG_BG3X = 0;
    REG_BG3Y = 0;
/*******************************************************************************************/

    /*  Establecer la afinidad del fondo 2 de la pantalla principal con color de 16 bits. */
    REG_BG2CNT = BG_BMP16_128x128 |
                 BG_BMP_BASE(8) | // La direccion inicial de memoria
                 BG_PRIORITY(2);  // Baja prioridad

    /*  Establecer la matriz de transformacion afin del fondo 2 de la pantalla principal 
        a la matriz de identidad. */
    REG_BG2PA = 1 << 8;
    REG_BG2PB = 0;
    REG_BG2PC = 0;
    REG_BG2PD = 1 << 8;

/*******************************************************************************************/
    /*  Definir la situacion del fondo 2 de la pantalla principal. */
    /*  Esto debera cambiar segun la posicion en la que se quiera poner el grafico */
    REG_BG2X = -(SCREEN_WIDTH / 2 - 32) << 8;
    REG_BG2Y = -32 << 8;
/*******************************************************************************************/

    /*  Establecer la afinidad del fondo 3 de la pantalla secundaria con color de 16 bits. */
    REG_BG3CNT_SUB = BG_BMP16_256x256 |
                     BG_BMP_BASE(0) | // La direccion inicial de memoria
                     BG_PRIORITY(3); // Baja prioridad

    /*  Establecer la matriz de transformacion afin del fondo 3 de la pantalla secundaria
        a la matriz de identidad. */
    REG_BG3PA_SUB = 1 << 8;
    REG_BG3PB_SUB = 0;
    REG_BG3PC_SUB = 0;
    REG_BG3PD_SUB = 1 << 8;

/*******************************************************************************************/
    /*  Definir la situacion del fondo 3 de la pantalla secundaria. */
    /*  Esto debera cambiar segun la posicion en la que se quiera poner el grafico */
    REG_BG3X_SUB = 0;
    REG_BG3Y_SUB = 0;
/*******************************************************************************************/
}

/* Para cada imagen que se quiera llevar a pantalla hay que hacer una de estas funciones. */

void SetFondo() {
    dmaCopyHalfWords(DMA_CHANNEL,
                     FondoBitmap, /* Variable generada automaticamente */
                     (uint16 *)BG_BMP_RAM(0), /* Direccion del fondo 3 principal */
                     FondoBitmapLen); /* Longitud (en bytes) generada automaticamente */
}

void SetFondoSub() {
    dmaCopyHalfWords(DMA_CHANNEL,
                     FondoBitmap, /* Variable generada automaticamente */
                     (uint16 *)BG_BMP_RAM_SUB(0), /* Direccion del fondo 3 principal */
                     FondoBitmapLen); /* Longitud (en bytes) generada automaticamente */
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/// graficos.c
/*---------------------------------------------------------------------------------
Este codigo se ha implementado basandose en el ejemplo "Simple sprite demo" de 
dovoto y otro de Jaeden Amero
---------------------------------------------------------------------------------*/

#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

/* Definir el sistema de video */
void initVideo() {
    /*  Mapear la memoria VRAM para mostrar graficos en las dos pantallas. */

    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_E_LCD);

    vramSetBankE(VRAM_E_MAIN_SPRITE);
    vramSetBankD(VRAM_D_SUB_SPRITE);

    /*  Establecer el modo de video de la pantalla principal. */
    videoSetMode(MODE_5_2D | // Establecer el modo grafico 5
                 DISPLAY_BG2_ACTIVE | // Activar el fondo 2
                 DISPLAY_BG3_ACTIVE); // Activar el fondo 3

    /*  Establecer el modo de video de la pantalla secundaria. */
    videoSetModeSub(MODE_5_2D | // Establecer el modo grafico 5
                    DISPLAY_BG3_ACTIVE); // Activar el fondo 3
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*-------------------------------------
 rutserv.c
-------------------------------------*/
// Anadir los includes que sean necesarios
#include <nds.h>
#include <stdio.h>
#include "teclado.h"
#include "defines.h"
#include "temporizadores.h"

// Este procedimiento inicializa la tabla de interrupciones para que el gestor de interrupciones sepa
// que rutina de atencion tiene que ejecutar cuando le llega una peticion de interrupcion. 
// Ademas es aqui donde se configuran los registros de control de los perifericos.

void HabilitarInterrupciones() { // En el Controlador de Interrupciones

  //Primero se inhiben todas las interrupciones
  
  //Escribir un 1 en el bit correspondiente 
  
  //Se vuelven a habilitar todas las interrupciones
  
}

void ProgramarRegistrosControl() { 
  
  //Registro de Control del Teclado
  
  //Registro de Control de los Temporizadores
  // TIMER0_CNT   
  //   El temporizador se activa poniendo un 1 en el bit 7.
  //   El temporizador interrumpira al desbordarse el contador, 
  //      si hay un 1 en el bit 6.
  //   Los dos bits de menos peso indican lo siguiente:
  //      00 frecuencia 33554432 hz
  //      01 frecuencia 33554432/64 hz
  //      10 frecuencia 33554432/256 hz
  //      11 frecuencia 33554432/1024 hz
  // TIMER0_DAT 
  //   Se utiliza para indicar a partir de que valor tiene que empezar a contar (latch)

}

void DefinirVectorInterrupciones() { // Rutinas de atencion

  //Rutina de Atencion al Teclado

  //Rutinas de Atencion a los Temporizadores

}

void InhibirInterrupciones() { // En el Controlador de Interrupciones

  //Primero se inhiben todas las interrupciones
  
  //Escribir un 0 en el bit correspondiente 

  //Se vuelven a habilitar todas las interrupciones
  	
}

void interrupciones(){

  HabilitarInterrupciones();
  ProgramarRegistrosControl();
  DefinirVectorInterrupciones();
 
}
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/// sprites.c
/*---------------------------------------------------------------------------------
Este codigo se ha implementado basandose en el ejemplo "Simple sprite demo" de 
dovoto y otro de Jaeden Amero
---------------------------------------------------------------------------------*/

#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "sprites.h"
#include "defines.h"

u16* gfxBillete;
u16* gfxSobre;

/* Inicializar la memoria de Sprites. */
void initSpriteMem() {

   //int i;
   oamInit(&oamMain, SpriteMapping_1D_32, false);
   oamInit(&oamSub, SpriteMapping_1D_32, false);

   gfxBillete = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
   gfxSobre   = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);

}

/* Dentro de esta funcion hay que definir el color con el que se mostrara cada uno de los 256 
 * colores posibles en la pantalla principal. El 0 es transparente y los no definidos son negros.
 */
void establecerPaletaPrincipal() {
                                         // 0: TRANSPARENTE
   SPRITE_PALETTE[1]  = RGB15(31,0,0);   // ROJO:           RGB24={FF,00,00}
   SPRITE_PALETTE[2]  = RGB15(31,31,0);  // AMARILLO:       RGB24={FF,FF,00}
   SPRITE_PALETTE[3]  = RGB15(31,31,31); // BLANCO:         RGB24={FF,FF,FF}
   SPRITE_PALETTE[4]  = RGB15(0,31,0);   // VERDE:          RGB24={00,FF,00}
   SPRITE_PALETTE[5]  = RGB15(0,0,31);   // AZUL:           RGB24={00,00,FF}
   SPRITE_PALETTE[6]  = RGB15(0,0,0);    // NEGRO:          RGB24={00,00,00}
   SPRITE_PALETTE[7]  = RGB15(0,31,31);  // CYAN:           RGB24={00,FF,FF}
   SPRITE_PALETTE[8]  = RGB15(31,0,31);  // MAGENTA:        RGB24={FF,00,FF}
   SPRITE_PALETTE[9]  = RGB15(16,16,16); // GRIS:           RGB24={80,80,80}
   SPRITE_PALETTE[10] = RGB15(25,25,25); // GRIS CLARO:     RGB24={D0,D0,D0}
   SPRITE_PALETTE[11] = RGB15(8,8,8);    // GRIS OSCURO:    RGB24={40,40,40}
   SPRITE_PALETTE[12] = RGB15(31,19,0);  // NARANJA:        RGB24={FF,99,00}
   SPRITE_PALETTE[13] = RGB15(19,0,4);   // GRANATE:        RGB24={99,00,21}
   SPRITE_PALETTE[14] = RGB15(25,0,0);   // MARRON:         RGB24={66,00,00}
   SPRITE_PALETTE[15] = RGB15(16,0,16);  // MORADO:         RGB24={80,00,80}
   SPRITE_PALETTE[16] = RGB15(25,19,31); // LILA:           RGB24={CC,99,FF}
   SPRITE_PALETTE[17] = RGB15(31,19,25); // ROSA:           RGB24={FF,99,CC}
   SPRITE_PALETTE[18] = RGB15(23,21,21); // AZUL CLARO:     RGB24={BB,FF,FF}
   SPRITE_PALETTE[19] = RGB15(0,0,16);   // AZUL MARINO:    RGB24={00,00,80}
   SPRITE_PALETTE[20] = RGB15(0,16,16);  // VERDE AZULADO:  RGB24={00,80,80}
   SPRITE_PALETTE[21] = RGB15(0,12,0);   // VERDE OSCURO:   RGB24={00,66,00}
   SPRITE_PALETTE[22] = RGB15(16,16,0);  // VERDE OLIVA:    RGB24={80,80,00}
   SPRITE_PALETTE[23] = RGB15(19,31,19); // VERDE CLARO:    RGB24={99,FF,99}
   SPRITE_PALETTE[24] = RGB15(31,31,19); // AMARILLO CLARO: RGB24={FF,FF,99}
}

/* Dentro de esta funcion hay que definir el color con el que se mostrara cada uno de los 256 
 * colores posibles en la pantalla secundaria. El 0 es transparente y los no definidos son negros.
 */
void establecerPaletaSecundaria() {
   SPRITE_PALETTE_SUB[1] = RGB15(0,31,0);   // los pixels a 1 se mostraran verdes
   SPRITE_PALETTE_SUB[2] = RGB15(31,31,31); // los pixels a 1 se mostraran blancos
   SPRITE_PALETTE_SUB[3] = RGB15(31,31,0);  // los pixels a 1 se mostraran amarillos
}

/* Dibujado de un Sprite de 16x16 pixels */

/* Debido al funcionamiento de los bancos de memoria, las primeras cuatro filas 
 * forman el cuadrante superior izquiero, las siguientes, el cuadrante superior 
 * derecho, las siguientes el cuadrante inferior izquierdo y las ultimas cuatro
 * filas, el cuadrante inferior derecho, como se muestra al lado.
 */

u8 Sobre[256] = 
{
   0,0,0,0,0,0,0,6,0,0,0,0,0,0,6,3,        // 0000000660000000
   0,0,0,0,0,6,3,3,0,0,0,0,6,3,3,3,        // 0000006336000000
   0,0,0,6,3,3,3,3,0,0,6,3,3,3,3,3,        // 0000063333600000
   0,6,3,3,3,3,3,3,6,3,6,24,24,24,24,24,   // 0000633333360000

   6,0,0,0,0,0,0,0,3,6,0,0,0,0,0,0,        // 0006333333336000
   3,3,6,0,0,0,0,0,3,3,3,6,0,0,0,0,        // 0063333333333600
   3,3,3,3,6,0,0,0,3,3,3,3,3,6,0,0,        // 0633333333333360
   3,3,3,3,3,3,6,0,24,24,24,24,24,6,3,6,   // 63624242424242424242424636

   6,3,3,6,24,24,24,24,6,3,3,3,6,24,24,24, // 633624242424242424246336
   6,3,3,3,3,6,24,24,6,3,3,3,3,3,6,24,     // 6333624242424242463336
   6,3,3,3,3,3,3,6,6,3,3,3,3,3,3,3,        // 63333624242424633336
   6,3,3,3,3,3,3,3,6,6,6,6,6,6,6,6,        // 633333624246333336

   24,24,24,24,6,3,3,6,24,24,24,6,3,3,3,6, // 6333333663333336
   24,24,6,3,3,3,3,6,24,6,3,3,3,3,3,6,     // 6333333333333336
   6,3,3,3,3,3,3,6,3,3,3,3,3,3,3,6,        // 6333333333333336
   3,3,3,3,3,3,3,6,6,6,6,6,6,6,6,6,        // 6666666666666666
};

u8 Billete[256] = 
{
   0,0,0,0,21,21,21,21,0,0,0,0,21,21,23,23, // 000021212121212121210000
   0,0,0,0,21,23,23,23,0,0,0,0,21,23,23,21, // 000021212323232321210000
   0,0,0,0,21,23,23,23,0,0,0,0,21,23,23,23, // 000021232323232323210000
   0,0,0,0,21,23,23,21,0,0,0,0,21,23,21,23, // 000021232321212323210000

   21,21,21,21,0,0,0,0,23,23,21,21,0,0,0,0, // 000021232323232323210000
   23,23,23,21,0,0,0,0,21,23,23,21,0,0,0,0, // 000021232323232323210000
   23,23,23,21,0,0,0,0,23,23,23,21,0,0,0,0, // 000021232321212323210000
   21,23,23,21,0,0,0,0,23,21,23,21,0,0,0,0, // 000021232123232123210000

   0,0,0,0,21,23,21,23,0,0,0,0,21,23,23,21, // 000021232123232123210000
   0,0,0,0,21,23,23,23,0,0,0,0,21,23,23,23, // 000021232321212323210000
   0,0,0,0,21,23,23,21,0,0,0,0,21,23,23,23, // 000021232323232323210000
   0,0,0,0,21,21,23,23,0,0,0,0,21,21,21,21, // 000021232323232323210000

   23,21,23,21,0,0,0,0,21,23,23,21,0,0,0,0, // 000021232321212323210000
   23,23,23,21,0,0,0,0,23,23,23,21,0,0,0,0, // 000021232323232323210000
   21,23,23,21,0,0,0,0,23,23,23,21,0,0,0,0, // 000021212323232321210000
   23,23,21,21,0,0,0,0,21,21,21,21,0,0,0,0, // 000021212121212121210000
};

/* Para cada Sprite que se quiera llevar a pantalla hay que hacer una de estas funciones. */

void BorrarBillete(int indice, int x, int y) {
oamSet(&oamMain, //main graphics engine context
	indice,  //oam index (0 to 127)  
	x, y,    //x and y pixle location of the sprite
	0,       //priority, lower renders last (on top)
	0,       //this is the palette index if multiple palettes or the alpha value if bmp sprite	
	SpriteSize_16x16,     
	SpriteColorFormat_256Color, 
	gfxBillete,//+16*16/2, 	//pointer to the loaded graphics
	-1,                  	//sprite rotation data  
	false,               	//double the size when rotating?
	true,			//hide the sprite?
	false, false, 		//vflip, hflip
	false			//apply mosaic
	); 
oamUpdate(&oamMain); 
}

void MostrarBillete (int indice, int x, int y){ 
oamSet(&oamMain, //main graphics engine context
	indice,  //oam index (0 to 127)  
	x, y,    //x and y pixle location of the sprite
	0,       //priority, lower renders last (on top)
	0,       //this is the palette index if multiple palettes or the alpha value if bmp sprite	
	SpriteSize_16x16,     
	SpriteColorFormat_256Color, 
	gfxBillete,//+16*16/2, 	//pointer to the loaded graphics
	-1,                  	//sprite rotation data  
	false,               	//double the size when rotating?
	false,			//hide the sprite?
	false, false, 		//vflip, hflip
	false			//apply mosaic
	); 
oamUpdate(&oamMain);  
}

void BorrarSobre(int x, int y){
oamSet(&oamMain, //main graphics engine context
	127,     //oam index (0 to 127)  
	x, y,    //x and y pixle location of the sprite
	0,       //priority, lower renders last (on top)
	0,       //this is the palette index if multiple palettes or the alpha value if bmp sprite	
	SpriteSize_16x16,     
	SpriteColorFormat_256Color, 
	gfxSobre,//+16*16/2,	//pointer to the loaded graphics
	-1,                  	//sprite rotation data  
	false,               	//double the size when rotating?
	true,			//hide the sprite?
	false, false, 		//vflip, hflip
	false			//apply mosaic
	); 
oamUpdate(&oamMain); 
}

void MostrarSobre (int x, int y){
oamSet(&oamMain, //main graphics engine context
	127,     //oam index (0 to 127)  
	x, y,    //x and y pixle location of the sprite
	0,       //priority, lower renders last (on top)
	0,       //this is the palette index if multiple palettes or the alpha value if bmp sprite	
	SpriteSize_16x16,     

	SpriteColorFormat_256Color, 
	gfxSobre,//+16*16/2,	//pointer to the loaded graphics
	-1,                  	//sprite rotation data  
	false,               	//double the size when rotating?
	false,			//hide the sprite?
	false, false, 		//vflip, hflip
	false			//apply mosaic
	); 
oamUpdate(&oamMain);  
}

void guardarSpritesEnMemoria(){ 
  int i;
  for(i = 0; i < 16 * 16 / 2; i++){ //muestra un cuadrado en la memoria de la pantalla principal		
     gfxBillete[i] = Billete[i*2] | (Billete[(i*2)+1]<<8);
     gfxSobre[i]   = Sobre[i*2]   | (Sobre[(i*2)+1]<<8);	

  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*-------------------------------------
 teclado.c
-------------------------------------*/

// Anadir los includes que sean necesarios
#include <nds.h>
#include <stdio.h>
#include "defines.h"
#include "sprites.h"

// Esta funcion tiene que devolver el valor de la tecla pulsada
int  TeclaPulsada() {
   // Devuelve el valor asociado a la tecla pulsada: 
   // A=0; B=1; Select=2; Start=3; Der=4; Izq=5;
   // Arriba=6; Abajo=7; R=8; L=9;
   // -1 en otros casos
   
}

// Rutina de atencion a la interrupcion del teclado
void IntTec() {
		
} 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
/*-------------------------------------
 temporizadores.c
-------------------------------------*/
// Anadir los includes que sean necesarios
#include "defines.h"
#include "sprites.h"
#include <nds.h>
#include <stdio.h>

// Rutina de atencion a la interrupcion del temporizador
void IntTemp() {

// ...

}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/// main.c
/*---------------------------------------------------
Este codigo se ha implementado basandose en el ejemplo "Simple sprite demo" de 
dovoto y otro de Jaeden Amero
---------------------------------------------------*/

#include <nds.h>
#include <stdio.h>
#include <stdlib.h>	    // srand, rand,...
#include <unistd.h>
#include <time.h>       // time 

#include "fondos.h"
#include "sprites.h"
#include "defines.h"
#include "rutservs.h"
#include "teclado.h"
#include "temporizadores.h"

//---------------------------------------------------
// Funciones
//---------------------------------------------------

// Esta funcion consulta si se ha tocado la pantalla tactil
int TactilTocada() {
    touchPosition pos_pantalla;
    touchRead(&pos_pantalla);
    return !(pos_pantalla.px==0 && pos_pantalla.py==0);
} 

//---------------------------------------------------
// Variables globales
//---------------------------------------------------

int estado;

//---------------------------------------------------
// main
//---------------------------------------------------

int main() {

    /* Definir variables */	
    touchPosition pos_pantalla;

    /* Poner en marcha el motor grafico 2D. */
    powerOn(POWER_ALL_2D);

    /* Establecer la pantalla inferior como principal, inicializar el sistema grafico
       y configurar el sistema de fondos. */
    lcdMainOnBottom();
    initVideo();
    initFondos();

    /* Mostrar fondos en pantalla. */
    SetFondo();
    //mostrarFondoSub();

    /* Inicializar memoria de sprites y guardar en ella los sprites */
    initSpriteMem();
    guardarSpritesEnMemoria();

    /* Establecer las paletas para los sprites */
    establecerPaletaPrincipal();
    establecerPaletaSecundaria();

    /* Inicializa la consola (superior) de texto. 
       Nota.- Para borrar la pantalla existe la funcion consoleClear() */
    consoleDemoInit();

    /* Para inicializar el generador de numeros aleatorios en funcion de una semilla,
        en este caso time(NULL). srand() solo se suele activar una vez por ejecucion y
        no devuelve ningun valor. 
        La funcion para generar valores aleatorios en el resto del programa es rand() */
    srand (time(NULL));	
	
    /* Incluimos la siguiente cabecera para que cada grupo la modifique con
        su numero de grupo "xx" en "Gxx". */
    iprintf("\x1b[02;00H  +--------------------------+  ");
    iprintf("\x1b[03;00H  : EC 17/18           Gxx   :  ");
    iprintf("\x1b[04;00H  +--------------------------+  ");

//---------------------------------------------------

    while( xxxxx ) {
	// ....

    } // while

} //main