-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgui.ino
197 lines (185 loc) · 5.36 KB
/
gui.ino
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
/* GUI for the handheld edition of the emulator
* Gui for File selection
* Gui for hardware configuration
* - Change keymaps
* - Load a snapshot
* - Reset the emulator
* - define hardware emulation
* - define keymaps
* - volver el emulador
* Gui confirmacion
*/
/* Borrar la parte de la pantalla a utilizar
* Escribir un titulo de la "ventana"
* varias opciones a elegir
* scroll si son mas que las que caben en pantalla
* mover una barra o algo entre las opciones
* retornar si/no y el resultado en funcion de la seleccion
*/
// GENERIC FUNCTIONS:
void gui_draw_window(int w,int h, char *title){
int x,y,n,m;
x=(320-w)/2;
y=(240-h)/2;
n=x+w-2;
m=y+8;
tft.fillRect(x-2,y-2,w+4,h+4,tft.color565(64,64,64));
tft.fillRect(x, y, w, 8,tft.color565(0,0,0));
tft.fillRect(x+1,y+9,w-2,h-9,tft.color565(255,255,255));
tft.drawRect(x, y+8,w, h-7,tft.color565(0,0,0));
tft.setCursor(x+2, y+1);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(1);
tft.println(title);
#ifdef USE_ADA
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
#else
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(255,0,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,0));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,255,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
tft.drawLine(n,y,(n--)-8,m,tft.color565(0,0,255));
#endif
}
void gui_update_menu(int w,int h,int n,int s, char data[][25]){
int c,x,y;
x=(320-w)/2;
y=(240-h)/2;
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(1);
for (c=1;c<=n;c++){
#ifdef USE_ADA
tft.fillRect(x+1,y+9*c,w-2,9,(c==s?ILI9341_CYAN:ILI9341_WHITE));
#else
tft.fillRect(x+1,y+9*c,w-2,9,(c==s?TFT_YELLOW:ILI9341_WHITE));
#endif
tft.setCursor(x+2, y+1+9*c);
tft.println(data[c-1]);
}
}
int gui_draw_menu(int w, char *title, int n, char data[][25]){
int ret=-1;
int h,b;
int s=1;
h=9+9*(n>7?7:n);
gui_draw_window(w,h,title);
gui_update_menu(w,h,n,s,data);
do {
b=mirabotones();
switch (b){
case 4:
if (s>1) {
s--;
gui_update_menu(w,h,n,s,data);
}
break;
case 5:
if (s<n) {
s++;
gui_update_menu(w,h,n,s,data);
}
break;
case 3:
ret=0;
break;
case 1:
ret=s;
break;
}
} while (ret == -1);
return ret;
}
// SPECIFIC FUNCTIONS
void gui_Main_Menu(void){
char options[7][25]={
"Cambiar Mapa de teclado",
"Cargar Snapshot",
"Cargar Cinta",
"Reset",
"Tipo de Maquina",
"Sonido ON/OFF",
"Volver"
};
int r;
r=gui_draw_menu(200,"Opciones",7,options);
switch (r){
case 1:
emuopt.mappingindex++ ;
if (emuopt.mappingindex>3) emuopt.mappingindex=0;
AS_printf("now mapping is "); AS_print(emuopt.mappingindex); AS_printf("\n");
break;
case 4:
reset_spectrum(&spectrumZ80);
break;
case 2:
Load_SNA(&spectrumZ80,"/manic.sna");
//gui_Select_Snap();
break;
case 6:
if (emuopt.sonido==1) {
emuopt.sonido=0;
dac_output_voltage(DAC_CHANNEL_1,0);
} else {
emuopt.sonido=1;
}
break;
/*
case 3:
gui_Select_Tape();
break;
*/
case 5:
// gui_Select_Machine();
show_splash();
do {
sleep(10);
} while (mirabotones()==0);
break;
}
tft.fillScreen(ILI9341_BLACK);
//tft.fillRect(0,0,320,240,tft.color565(0,0,0));
for(r=0;r<(320*240);r++){ *(lastpix+r)=0; }
}
void show_splash(void){
gui_draw_window(270,170, "Version 0.0 alpha");
tft.setCursor(0, 65);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(3);
tft.println(" OpenVEGA+");
tft.setTextColor(ILI9341_DARKGREEN);
tft.setTextSize(2);
tft.println("\n By Alvaro Alea F.");
tft.setTextSize(1);
tft.println("");
tft.setTextSize(2);
tft.println(" (C) 2019");
tft.setTextSize(1);
tft.setTextColor(ILI9341_BLUE);
tft.println("\n\n\n A Opensource Portable Spectrum Emulator");
}