mirror of
https://github.com/shadlyd15/NesUEFI.git
synced 2024-09-15 15:03:14 +00:00
GFX experiments
This commit is contained in:
parent
8bf95bce0c
commit
fa0c4640ac
@ -102,6 +102,7 @@ img:
|
|||||||
mcopy -i $(IMAGE).img splash.bmp ::
|
mcopy -i $(IMAGE).img splash.bmp ::
|
||||||
# Add your roms here
|
# Add your roms here
|
||||||
mcopy -i $(IMAGE).img nestest.nes ::
|
mcopy -i $(IMAGE).img nestest.nes ::
|
||||||
|
mcopy -i $(IMAGE).img SMB.nes ::
|
||||||
|
|
||||||
run:
|
run:
|
||||||
qemu-system-x86_64 -drive format=raw,file=$(IMAGE).img -m 256M -cpu qemu64 \
|
qemu-system-x86_64 -drive format=raw,file=$(IMAGE).img -m 256M -cpu qemu64 \
|
||||||
|
Binary file not shown.
BIN
NesUEFI/SMB.nes
Normal file
BIN
NesUEFI/SMB.nes
Normal file
Binary file not shown.
@ -112,20 +112,16 @@ EFI_STATUS graphics_set_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop){
|
|||||||
|
|
||||||
for (i = 0; i < imax; i++) {
|
for (i = 0; i < imax; i++) {
|
||||||
UINTN SizeOfInfo;
|
UINTN SizeOfInfo;
|
||||||
rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo,
|
rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info);
|
||||||
&info);
|
|
||||||
if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) {
|
if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) {
|
||||||
Print(L"gop->QueryMode() returned %r\n", rc);
|
Print(L"gop->QueryMode() returned %r\n", rc);
|
||||||
Print(L"Trying to start GOP with SetMode().\n");
|
Print(L"Trying to start GOP with SetMode().\n");
|
||||||
rc = uefi_call_wrapper(gop->SetMode, 2, gop,
|
rc = uefi_call_wrapper(gop->SetMode, 2, gop, gop->Mode ? gop->Mode->Mode : 0);
|
||||||
gop->Mode ? gop->Mode->Mode : 0);
|
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)) {
|
if (EFI_ERROR(rc)) {
|
||||||
Print(L"%d: Bad response from QueryMode: %r (%d)\n",
|
Print(L"%d: Bad response from QueryMode: %r (%d)\n", i, rc, rc);
|
||||||
i, rc, rc);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <efi.h>
|
#include <efi.h>
|
||||||
|
|
||||||
#define TICK_PER_SECOND 120
|
#define TICK_PER_SECOND 150
|
||||||
|
|
||||||
EFI_STATUS timer_init(uint32_t tps);
|
EFI_STATUS timer_init(uint32_t tps);
|
||||||
unsigned long long timer_ticks();
|
unsigned long long timer_ticks();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "../ui/adafruit_gfx.h"
|
#include "../ui/adafruit_gfx.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// 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];
|
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(){
|
void nes_gfx_swap(){
|
||||||
for (int i = 0; i < NES_SCREEN_WIDTH*NES_SCREEN_HEIGHT; ++i){
|
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 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;
|
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,
|
fillRect( x_offset + (i%NES_SCREEN_WIDTH)*NES_SCREEN_ZOOM,
|
||||||
y_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]);
|
NES_SCREEN_ZOOM, NES_SCREEN_ZOOM, _nes_screen_buffer_current[i]);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,30 +43,33 @@ efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab){
|
|||||||
rc = graphics_init(&gop);
|
rc = graphics_init(&gop);
|
||||||
if (rc == EFI_SUCCESS){
|
if (rc == EFI_SUCCESS){
|
||||||
Print(L"Graphics Protocol Intialized : %r\n", rc);
|
Print(L"Graphics Protocol Intialized : %r\n", rc);
|
||||||
|
// graphics_print_modes(gop);
|
||||||
rc = graphics_set_mode(gop);
|
rc = graphics_set_mode(gop);
|
||||||
if (rc == EFI_SUCCESS){
|
if (rc == EFI_SUCCESS){
|
||||||
Print(L"Graphics Mode Set : %r\n", rc);
|
Print(L"Graphics Mode Set : %r\n", rc);
|
||||||
Print(L"\a");
|
Print(L"\a");
|
||||||
kernel.graphics = gop;
|
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);
|
#if 1
|
||||||
list_file_browser();
|
|
||||||
keyboard_init(ui_key_handler);
|
|
||||||
|
|
||||||
unsigned long last_frame = 0;
|
unsigned long last_frame = 0;
|
||||||
while(1){
|
while(rc == EFI_SUCCESS){
|
||||||
keyboard_poll();
|
keyboard_poll();
|
||||||
|
ui_state_t state = ui_manage_states();
|
||||||
const unsigned long now = (unsigned long)timer_ticks();
|
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;
|
last_frame = now;
|
||||||
ui_state_t state = ui_manage_states();
|
|
||||||
if(state == UI_STATE_PLAY){
|
if(state == UI_STATE_PLAY){
|
||||||
nes_gfx_swap();
|
nes_gfx_swap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Print(L"EFI EXIT : %r\n", rc);
|
Print(L"EFI EXIT : %r\n", rc);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
BIN
NesUEFI/main.efi
BIN
NesUEFI/main.efi
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
Loading…
Reference in New Issue
Block a user