@@ -31,6 +31,7 @@ int main(int argc, char* args[]) {
3131 Uint16 cellsStartAddress = 0x0 ; // For CM rendering
3232 bool clicked = false , refresh = true , constantRefresh = false ;
3333 bool fullInstruction = false , constantFullInstruction = false , progressBarAll = false ;
34+ Uint8 key; // For keyboard input
3435
3536 // Interpreter
3637 SystemBus SB;
@@ -70,6 +71,7 @@ int main(int argc, char* args[]) {
7071 SDL_Texture* fontTexture = Window.loadTexture (" res/img/font.png" );
7172 SDL_Texture* cpuGuiTexture = Window.loadTexture (" res/img/cpu_gui.png" );
7273 SDL_Texture* cmGuiTexture = Window.loadTexture (" res/img/cm_gui.png" );
74+ SDL_Texture* iodGuiTexture = Window.loadTexture (" res/img/iod_gui.png" );
7375 SDL_Texture* sbGuiTexture = Window.loadTexture (" res/img/system_bus_gui.png" );
7476 SDL_Texture* progressBarTexture = Window.loadTexture (" res/img/progress_bar.png" );
7577 SDL_Texture* progressBarNowTexture = Window.loadTexture (" res/img/progress_bar_now.png" );
@@ -90,7 +92,8 @@ int main(int argc, char* args[]) {
9092 // GUI backgrounds
9193 Entity cpuGui (Vector2f (6 , 10 ), cpuGuiTexture, 256 , 128 );
9294 Entity cmGui (Vector2f (70 , 10 ), cmGuiTexture, 256 , 128 );
93- Entity sbGui (Vector2f (6 , 121 ), sbGuiTexture, 128 , 256 );
95+ Entity iodGui (Vector2f (111 , 58 ), iodGuiTexture, 256 , 128 );
96+ Entity sbGui (Vector2f (6 , 121 ), sbGuiTexture, 128 , 384 );
9497 // Instruction name
9598 TextEntity instNameTitle (Vector2f (32 , 3 ), fontTexture, &font);
9699 TextEntity instNameValue (Vector2f (82 , 3 ), fontTexture, &font);
@@ -212,6 +215,7 @@ int main(int argc, char* args[]) {
212215 }
213216 msNext = msNow + msStep;
214217 clicked = false ;
218+ key = 0x0 ;
215219 // Controls
216220 while (SDL_PollEvent (&event)) {
217221 switch (event.type ) {
@@ -241,6 +245,25 @@ int main(int argc, char* args[]) {
241245 cellsStartAddress = settings.interpreter .ramSize - (4 - cellsStartAddress);
242246 }
243247 break ;
248+ case SDL_KEYDOWN:
249+ SDL_Scancode code = event.key .keysym .scancode ;
250+ if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z) {
251+ key = code + 93 ;
252+ }
253+ else if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9) {
254+ key = code + 19 ;
255+ }
256+ else if (code >= SDL_SCANCODE_KP_1 && code <= SDL_SCANCODE_KP_9) {
257+ key = code - 40 ;
258+ }
259+ else if (code == SDL_SCANCODE_0 || code == SDL_SCANCODE_KP_0) {
260+ key = ' 0' ;
261+ }
262+ else if (code == SDL_SCANCODE_KP_ENTER) {
263+ key = ' \n ' ;
264+ }
265+ IOD.input (key);
266+ break ;
244267 }
245268 }
246269 // Actual processing
@@ -370,6 +393,7 @@ int main(int argc, char* args[]) {
370393 // GUI backgrounds
371394 Window.renderGui (cpuGui);
372395 Window.renderGui (cmGui);
396+ Window.renderGui (iodGui);
373397 Window.renderGui (sbGui);
374398 // CPU Render
375399 Window.renderText (cpuTitle);
0 commit comments