Skip to content

Commit

Permalink
Update win32 files
Browse files Browse the repository at this point in the history
(they are not working version, but at least they are not complaining either)
  • Loading branch information
Godzil committed Feb 3, 2018
1 parent cdda587 commit 46683a8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ else (TARGET_TI68k)
add_subdirectory(os/unix)
endif (TARGET_TI68k)

find_library(PTHREADLIB pthread)
#find_library(PTHREADLIB pthread)

if (COVERALLS)
set(COVERAGE_SRCS src/main.c src/paddle.c src/NESCarts.c ${COVERAGE_SRCS})
Expand All @@ -101,7 +101,7 @@ if (COVERALLS)
) # (Optional) Alternate project cmake module path.
endif ()

target_link_libraries(petines apu corecpu mappermanager memorymanager pluginsmanager ppu oslib ${PTHREADLIB})
target_link_libraries(petines apu corecpu mappermanager memorymanager pluginsmanager ppu oslib)# ${PTHREADLIB})

add_test(NAME petines_test_1 COMMAND $<TARGET_FILE:petines> ${PROJECT_SOURCE_DIR}/data/bad_apple_2.nes)
add_test(NAME petines_test_2 COMMAND $<TARGET_FILE:petines> ${PROJECT_SOURCE_DIR}/data/trollburner_demo.nes)
65 changes: 37 additions & 28 deletions src/os/win32/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,36 @@

#include <os_dependent.h>

#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
#include <OpenGL/glext.h>

/* "Apple" fix */
#ifndef GL_TEXTURE_RECTANGLE
#define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_EXT
#endif

#include <palette.h>

typedef struct GLWindow_t GLWindow;

struct KeyArray
{
uint8_t lastState;
uint8_t curState;
uint8_t debounced;
GLFWwindow* window;
uint8_t lastState;
uint8_t curState;
uint8_t debounced;
GLFWwindow* window;
};

struct GLWindow_t
{
struct KeyArray keyArray[512];
GLFWwindow* windows;
uint8_t *videoMemory;
GLint videoTexture;
int WIDTH;
int HEIGHT;
struct KeyArray keyArray[512];
GLFWwindow* windows;
uint8_t *videoMemory;
GLint videoTexture;
int WIDTH;
int HEIGHT;
};

#ifndef GL_TEXTURE_RECTANGLE_EXT
#define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV
#endif

static int window_num = 0;

void GLWindowInitEx(GLWindow *g, int w, int h)
Expand All @@ -58,10 +59,10 @@ void GLWindowInit(GLWindow *g)

void ShowScreen(GLWindow *g, int w, int h)
{
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, g->videoTexture);
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);

// glTexSubImage2D is faster when not using a texture range
glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
glBegin(GL_QUADS);

glTexCoord2f(0.0f, 0.0f);
Expand Down Expand Up @@ -99,20 +100,20 @@ void setupGL(GLWindow *g, int w, int h)
glLoadIdentity();

glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_RECTANGLE_EXT);
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, g->videoTexture);
glEnable(GL_TEXTURE_RECTANGLE);
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);

// glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);

// glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
// glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);

glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, w,
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w,
h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);

glDisable(GL_DEPTH_TEST);
Expand All @@ -135,7 +136,7 @@ void restoreGL(GLWindow *g, int w, int h)
glLoadIdentity();

glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_RECTANGLE_EXT);
glEnable(GL_TEXTURE_RECTANGLE);
glDisable(GL_DEPTH_TEST);
}

Expand Down Expand Up @@ -164,6 +165,10 @@ void sizeHandler(GLFWwindow* window,int xs,int ys)
glViewport(0, 0, xs, ys);
}

static void error_callback(int error, const char* description)
{
puts(description);
}

void initDisplay(GLWindow *g)
{
Expand All @@ -173,14 +178,18 @@ void initDisplay(GLWindow *g)
/// Initialize GLFW
glfwInit();

glfwSetErrorCallback(error_callback);

// Open screen OpenGL window
if( !(g->windows=glfwCreateWindow( g->WIDTH, g->HEIGHT, "Main", NULL, NULL)) )
{
glfwTerminate();
fprintf(stderr, "Window creation error...\n");
return;
abort();
}

glfwSetWindowAspectRatio(g->windows, 4, 3);

glfwMakeContextCurrent(g->windows);
setupGL(g, g->WIDTH, g->HEIGHT);

Expand All @@ -198,7 +207,7 @@ void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
{
uint8_t r,g,b,a;

uint32_t offset = (y*gw->WIDTH*4)+4*x;
uint32_t offset = (y*gw->WIDTH*4U)+4U*x;

if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
return;
Expand Down Expand Up @@ -288,7 +297,7 @@ void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
}
}

exit:
exit:
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/os/win32/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int console_printf(const ConsoleLevel level, const char *format, ...)
va_list ap;
va_start(ap, format);

ret = console_vprintf(level, format, ap);
console_vprintf(level, format, ap);

va_end(ap);
return 0;
Expand Down
5 changes: 3 additions & 2 deletions src/os/win32/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string.h>
#include <signal.h>

#include <sys/mman.h>
//#include <sys/mman.h>

#include <sys/types.h>
#include <sys/stat.h>
Expand All @@ -26,7 +26,8 @@ void *LoadFilePtr(char * filename)

fstat(fd, &FileStat);

RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
RetPtr = NULL;
// RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);

close(fd);

Expand Down

0 comments on commit 46683a8

Please sign in to comment.