diff --git a/NesUEFI/Makefile b/NesUEFI/Makefile index 5c5d8c2..06a50e6 100644 --- a/NesUEFI/Makefile +++ b/NesUEFI/Makefile @@ -102,6 +102,7 @@ img: mcopy -i $(IMAGE).img splash.bmp :: # Add your roms here mcopy -i $(IMAGE).img nestest.nes :: + mcopy -i $(IMAGE).img SMB.nes :: run: qemu-system-x86_64 -drive format=raw,file=$(IMAGE).img -m 256M -cpu qemu64 \ diff --git a/NesUEFI/NesUEFI.img b/NesUEFI/NesUEFI.img index 7b0cece..5059149 100644 Binary files a/NesUEFI/NesUEFI.img and b/NesUEFI/NesUEFI.img differ diff --git a/NesUEFI/SMB.nes b/NesUEFI/SMB.nes new file mode 100644 index 0000000..878ef21 Binary files /dev/null and b/NesUEFI/SMB.nes differ diff --git a/NesUEFI/driver/graphics.c b/NesUEFI/driver/graphics.c index d5d58c0..cce59c1 100644 --- a/NesUEFI/driver/graphics.c +++ b/NesUEFI/driver/graphics.c @@ -112,20 +112,16 @@ EFI_STATUS graphics_set_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop){ for (i = 0; i < imax; i++) { UINTN SizeOfInfo; - rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, - &info); + rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info); if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) { Print(L"gop->QueryMode() returned %r\n", rc); Print(L"Trying to start GOP with SetMode().\n"); - rc = uefi_call_wrapper(gop->SetMode, 2, gop, - gop->Mode ? gop->Mode->Mode : 0); - rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, - &SizeOfInfo, &info); + rc = uefi_call_wrapper(gop->SetMode, 2, gop, gop->Mode ? gop->Mode->Mode : 0); + rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info); } if (EFI_ERROR(rc)) { - Print(L"%d: Bad response from QueryMode: %r (%d)\n", - i, rc, rc); + Print(L"%d: Bad response from QueryMode: %r (%d)\n", i, rc, rc); continue; } diff --git a/NesUEFI/driver/timer.h b/NesUEFI/driver/timer.h index d624e99..5100e47 100644 --- a/NesUEFI/driver/timer.h +++ b/NesUEFI/driver/timer.h @@ -3,7 +3,7 @@ #include -#define TICK_PER_SECOND 120 +#define TICK_PER_SECOND 150 EFI_STATUS timer_init(uint32_t tps); unsigned long long timer_ticks(); diff --git a/NesUEFI/hal/nes_gfx_hal.c b/NesUEFI/hal/nes_gfx_hal.c index c0c8f50..a6a6f3e 100644 --- a/NesUEFI/hal/nes_gfx_hal.c +++ b/NesUEFI/hal/nes_gfx_hal.c @@ -3,7 +3,7 @@ #include "../ui/adafruit_gfx.h" #include -// UINT32 _nes_screen_buffer_prev[(NES_SCREEN_WIDTH) * (NES_SCREEN_HEIGHT) + 1]; +UINT32 _nes_screen_buffer_prev[(NES_SCREEN_WIDTH) * (NES_SCREEN_HEIGHT) + 1]; UINT32 _nes_screen_buffer_current[(NES_SCREEN_WIDTH) * (NES_SCREEN_HEIGHT) + 1]; @@ -21,13 +21,13 @@ void nes_set_bg(int colour){ void nes_gfx_swap(){ for (int i = 0; i < NES_SCREEN_WIDTH*NES_SCREEN_HEIGHT; ++i){ - // if((_nes_screen_buffer_current[i] != _nes_screen_buffer_prev[i]) ){ + if((_nes_screen_buffer_current[i] != _nes_screen_buffer_prev[i]) ){ int x_offset = (kernel.graphics->Mode->Info->HorizontalResolution - NES_SCREEN_WIDTH*NES_SCREEN_ZOOM)/2 +1; int y_offset = (kernel.graphics->Mode->Info->VerticalResolution - NES_SCREEN_HEIGHT*NES_SCREEN_ZOOM)/2; - // _nes_screen_buffer_prev[i] = _nes_screen_buffer_current[i]; + _nes_screen_buffer_prev[i] = _nes_screen_buffer_current[i]; fillRect( x_offset + (i%NES_SCREEN_WIDTH)*NES_SCREEN_ZOOM, y_offset + (i/NES_SCREEN_WIDTH)*NES_SCREEN_ZOOM, NES_SCREEN_ZOOM, NES_SCREEN_ZOOM, _nes_screen_buffer_current[i]); - // } + } } } \ No newline at end of file diff --git a/NesUEFI/main.c b/NesUEFI/main.c index 2da1f28..9f3d4fa 100644 --- a/NesUEFI/main.c +++ b/NesUEFI/main.c @@ -43,30 +43,33 @@ efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab){ rc = graphics_init(&gop); if (rc == EFI_SUCCESS){ Print(L"Graphics Protocol Intialized : %r\n", rc); + // graphics_print_modes(gop); rc = graphics_set_mode(gop); if (rc == EFI_SUCCESS){ Print(L"Graphics Mode Set : %r\n", rc); Print(L"\a"); kernel.graphics = gop; + + adafruit_gfx_init(kernel.graphics->Mode->Info->HorizontalResolution, kernel.graphics->Mode->Info->VerticalResolution); + list_file_browser(); + keyboard_init(ui_key_handler); } } - adafruit_gfx_init(kernel.graphics->Mode->Info->HorizontalResolution, kernel.graphics->Mode->Info->VerticalResolution); - list_file_browser(); - keyboard_init(ui_key_handler); - + #if 1 unsigned long last_frame = 0; - while(1){ + while(rc == EFI_SUCCESS){ keyboard_poll(); + ui_state_t state = ui_manage_states(); const unsigned long now = (unsigned long)timer_ticks(); - if ((now - last_frame) > TICK_PER_SECOND/NES_FPS){ + if ((now - last_frame) > TICK_PER_SECOND/NES_FPS*1.0){ last_frame = now; - ui_state_t state = ui_manage_states(); if(state == UI_STATE_PLAY){ nes_gfx_swap(); } } } + #endif Print(L"EFI EXIT : %r\n", rc); return EFI_SUCCESS; diff --git a/NesUEFI/main.efi b/NesUEFI/main.efi index 85ced30..df71e6d 100755 Binary files a/NesUEFI/main.efi and b/NesUEFI/main.efi differ diff --git a/NesUEFI/splash.bmp b/NesUEFI/splash.bmp index 1a2a9b4..609c2f0 100644 Binary files a/NesUEFI/splash.bmp and b/NesUEFI/splash.bmp differ