diff --git a/emulator_shell.c b/emulator_shell.c index 4d508a0..a77617f 100644 --- a/emulator_shell.c +++ b/emulator_shell.c @@ -7,6 +7,8 @@ // gcc emulator_shell.c `pkg-config --cflags --libs gtk+-3.0` -o emulator #define FREQUENCY 500 +void keyDown(uint8_t key); +void keyUp(uint8_t key); //===== GTK SETUP ===== @@ -74,8 +76,6 @@ static gboolean on_key_release(GtkWidget *widget, GdkEventKey *event, gpointer u keyUp(4); break; } - } - return FALSE; } @@ -625,8 +625,7 @@ int emulate8080(State8080* state) { uint32_t hl = (state->h << 8) | state->l; uint32_t result = hl + hl; state->h = (result & 0xff00) >> 8; - state->l = result & 0xff;0[*opcode]; -} + state->l = result & 0xff; state->cc.cy = ((result & 0xffff0000) != 0); } break; @@ -810,9 +809,11 @@ int emulate8080(State8080* state) { state->sp += 2; break; case 0xd3: // OUT byte + { uint8_t port = opcode[1]; machineOut(state, port, 0x00); // PROBLEM: We need to pass a value to machineOUT state->pc++; + } break; case 0xd5: // PUSH D state->memory[state->sp-1] = state->d; @@ -820,9 +821,11 @@ int emulate8080(State8080* state) { state->sp -= 2; break; case 0xdb: // IN byte + { uint8_t port = opcode[1]; state->a = machineIn(state, port); state->pc++; + } break; case 0xe1: // POP H state->l = state->memory[state->sp]; @@ -1011,6 +1014,7 @@ int main (int argc, char *argv[]) { read_Space_Invaders_ROM(state, "ROM/invaders.g", 0x800); read_Space_Invaders_ROM(state, "ROM/invaders.f", 0x1000); read_Space_Invaders_ROM(state, "ROM/invaders.e", 0x1800); + gtk_main(); @@ -1025,8 +1029,9 @@ int main (int argc, char *argv[]) { i++; simulateNanoseconds(FREQUENCY * counter); // EMULATION OF THE PROCESSOR ŠPEED - if ((total_count > 10000000) && (state->int_enable)) //1/60 second has elapsed + if ((total_count > 16000000) && (state->int_enable)) //1/60 second has elapsed { + // draw_screen(state); if (which_interrupt == 2) { generateInterrupt(state, 2); //interrupt 2 total_count = 0; @@ -1038,7 +1043,7 @@ int main (int argc, char *argv[]) { } } } - gtk_main(); + free(state->memory); free(state); return 0;