Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5336cf6272 | ||
|
|
29a2deb1f3 | ||
|
|
05f17740fd | ||
|
|
6e179a5866 | ||
|
|
a6586b3467 | ||
|
|
79e43a98e4 | ||
|
|
9413fc5e27 | ||
|
|
1158daab8b | ||
|
|
6f2bf79917 | ||
|
|
c7c21ce752 | ||
|
|
8b34ba6c26 | ||
|
|
e8171d4705 | ||
|
|
f5c15c741b | ||
|
|
1ac164cbda | ||
|
|
4da1c434cd | ||
|
|
6a1064a852 | ||
|
|
0a0d086f31 | ||
|
|
a09f33fe33 | ||
|
|
b6c4793f44 | ||
|
|
b0ed951235 | ||
|
|
ff80e60879 | ||
|
|
bfd4597afa | ||
|
|
7ffe343e7a | ||
|
|
75bac739ee | ||
|
|
779a22006c | ||
|
|
3d3d6729f6 | ||
|
|
d26bd788cf |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[submodule "external/glfw"]
|
||||
path = external/glfw
|
||||
url = https://github.com/glfw/glfw.git
|
||||
[submodule "external/coveralls-cmake"]
|
||||
path = external/coveralls-cmake
|
||||
url = https://github.com/JoakimSoderberg/coveralls-cmake.git
|
||||
|
||||
40
.travis.yml
Normal file
40
.travis.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
language: c
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
matrix:
|
||||
allow_failures:
|
||||
- os: osx
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- lcov
|
||||
- curl
|
||||
- xorg-dev
|
||||
- libglu1-mesa-dev
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=OFF -DCMAKE_BUILD_TYPE=Release ..
|
||||
- cmake --build .
|
||||
- cd ..
|
||||
- mkdir coverage
|
||||
- cd coverage
|
||||
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target coveralls
|
||||
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install glew; fi
|
||||
|
||||
install: true
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
@@ -9,7 +9,9 @@
|
||||
# $HeadURL$
|
||||
# $Revision$
|
||||
|
||||
cmake_minimum_required (VERSION 3.6)
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
project (TINES)
|
||||
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
@@ -19,6 +21,8 @@ find_package(OpenGL REQUIRED)
|
||||
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
|
||||
project (TINES)
|
||||
if (COVERALLS)
|
||||
enable_testing()
|
||||
endif (COVERALLS)
|
||||
|
||||
add_subdirectory (src)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
TI-NESulator
|
||||
============
|
||||
|
||||
This is a cleaned version of the TI-NESulator repository (all data has been removed)
|
||||
[](https://coveralls.io/github/Godzil/TI-NESulator?branch=master) [](https://codecov.io/gh/Godzil/TI-NESulator) [](https://travis-ci.org/Godzil/TI-NESulator)
|
||||
|
||||
This is a cleaned version of the TI-NESulator repository (all non free data has been removed)
|
||||
|
||||
Some part of the original subversion has been lost because of harddrive crash so the
|
||||
early stage of the project is completely lost. Or I would need to check all the
|
||||
|
||||
BIN
data/bad_apple_2.nes
Normal file
BIN
data/bad_apple_2.nes
Normal file
Binary file not shown.
BIN
data/trollburner_demo.nes
Normal file
BIN
data/trollburner_demo.nes
Normal file
Binary file not shown.
1
external/coveralls-cmake
vendored
Submodule
1
external/coveralls-cmake
vendored
Submodule
Submodule external/coveralls-cmake added at e37d5b8674
2
external/glfw
vendored
2
external/glfw
vendored
Submodule external/glfw updated: 0f488ac286...525ad7bfb8
@@ -22,12 +22,16 @@ set(USE_PROFILING OFF CACHE BOOL "Use profiling tools? (Will slow down a lot.)")
|
||||
|
||||
set(USE_ALLEGRO ON CACHE BOOL "Use Allegro backend")
|
||||
|
||||
option(COVERALLS "Generate coveralls data" OFF)
|
||||
|
||||
##########################
|
||||
# Link & Compile flags
|
||||
##########################
|
||||
|
||||
set (CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Werror ${PLATFORM_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Werror ${PLATFORM_FLAGS}")
|
||||
set (CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Werror ${PLATFORM_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Werror ${PLATFORM_FLAGS}")
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake)
|
||||
|
||||
add_definitions (-DNO_DECIMAL)
|
||||
|
||||
@@ -59,6 +63,12 @@ if (USE_PROFILING)
|
||||
set(CMAKE_C_FLAGS -pg)
|
||||
endif (USE_PROFILING)
|
||||
|
||||
if (COVERALLS)
|
||||
add_definitions (-DRUN_COVERAGE)
|
||||
include(Coveralls)
|
||||
coveralls_turn_on_coverage()
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
|
||||
add_subdirectory(apu)
|
||||
@@ -79,5 +89,18 @@ endif (TARGET_TI68k)
|
||||
|
||||
find_library(PTHREADLIB pthread)
|
||||
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/main.c src/paddle.c src/NESCarts.c ${COVERAGE_SRCS})
|
||||
|
||||
# Create the coveralls target.
|
||||
coveralls_setup(
|
||||
"${COVERAGE_SRCS}" # The source files.
|
||||
ON # If we should upload.
|
||||
) # (Optional) Alternate project cmake module path.
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(tines main.c paddle.c NESCarts.c)
|
||||
target_link_libraries(tines apu corecpu mappermanager memorymanager pluginsmanager ppu oslib ${PTHREADLIB})
|
||||
target_link_libraries(tines apu corecpu mappermanager memorymanager pluginsmanager ppu oslib ${PTHREADLIB})
|
||||
|
||||
add_test(NAME tines_test COMMAND $<TARGET_FILE:tines> ${PROJECT_SOURCE_DIR}/data/bad_apple_2.nes)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <NESCarts.h>
|
||||
#include <os_dependent.h>
|
||||
#include <mappers/manager.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
void DumpCartProperties(FILE *out, NesCart * cart)
|
||||
{
|
||||
@@ -57,7 +58,7 @@ int LoadCart(const char *filename, NesCart * cart)
|
||||
cart->File = (byte *)LoadFilePtr((char *)filename);
|
||||
|
||||
|
||||
if ((cart->File == NULL) || ((int)cart->File == -1))
|
||||
if ((cart->File == NULL) || (cart->File == MAP_FAILED))
|
||||
return -1;
|
||||
|
||||
sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
|
||||
|
||||
@@ -9,4 +9,8 @@
|
||||
# $HeadURL$
|
||||
# $Revision$
|
||||
|
||||
add_library(corecpu corecpu.c)
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/corecpu/corecpu.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_library(corecpu corecpu.c)
|
||||
|
||||
37
src/main.c
37
src/main.c
@@ -73,7 +73,7 @@ double APU_BASEFREQ = 1.7897725;
|
||||
|
||||
/* TI-NESulator Version */
|
||||
#define V_MAJOR 0
|
||||
#define V_MINOR 70
|
||||
#define V_MINOR 71
|
||||
|
||||
#ifdef USE_SOUND
|
||||
#undef USE_SOUND
|
||||
@@ -150,7 +150,7 @@ void SaveSaveRam(char *name)
|
||||
FILE *fp;
|
||||
int i;
|
||||
char fname[512];
|
||||
int ret;
|
||||
|
||||
strcpy(fname, name);
|
||||
strcat(fname, ".svt");
|
||||
if ((fp = fopen(fname, "wb")))
|
||||
@@ -158,7 +158,7 @@ void SaveSaveRam(char *name)
|
||||
console_printf(Console_Default, "Saving savestate '%s'\n", fname);
|
||||
for( i = 0x60; i < 0x80; i++)
|
||||
{
|
||||
ret = fwrite(get_page_ptr(i), 1, 0x100, fp);
|
||||
fwrite(get_page_ptr(i), 1, 0x100, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
@@ -170,7 +170,7 @@ void LoadSaveRam(char *name)
|
||||
FILE *fp;
|
||||
int i;
|
||||
char fname[512];
|
||||
int ret;
|
||||
|
||||
strcpy(fname, name);
|
||||
strcat(fname, ".svt");
|
||||
if ((fp = fopen(fname, "rb")))
|
||||
@@ -178,7 +178,7 @@ void LoadSaveRam(char *name)
|
||||
console_printf(Console_Default, "Loading savestate '%s'\n", fname);
|
||||
for( i = 0x60; i < 0x80; i++)
|
||||
{
|
||||
ret = fread(get_page_ptr(i), 1, 0x0100, fp);
|
||||
fread(get_page_ptr(i), 1, 0x0100, fp);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
@@ -189,7 +189,6 @@ void LoadSaveRam(char *name)
|
||||
void LoadPalette(char *filename, Palette *pal)
|
||||
{
|
||||
FILE *fp;
|
||||
int ret;
|
||||
unsigned char r, v, b, i;
|
||||
console_printf(Console_Default, "%s: try to load pallette file '%s'", __func__, filename);
|
||||
if ((fp = fopen(filename, "rb")) != NULL)
|
||||
@@ -198,9 +197,9 @@ void LoadPalette(char *filename, Palette *pal)
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
|
||||
ret = fread(&r, 1, 1, fp);
|
||||
ret = fread(&v, 1, 1, fp);
|
||||
ret = fread(&b, 1, 1, fp);
|
||||
fread(&r, 1, 1, fp);
|
||||
fread(&v, 1, 1, fp);
|
||||
fread(&b, 1, 1, fp);
|
||||
|
||||
/* r = (r * 64) / 255;
|
||||
v = (v * 64) / 255;
|
||||
@@ -258,12 +257,20 @@ void LoadPalette(char *filename, Palette *pal)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RUN_COVERAGE
|
||||
void alarmHandler(int sig)
|
||||
{
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
WantClosing = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void signalhandler(int sig)
|
||||
{
|
||||
static int state=0;
|
||||
|
||||
char name[512];
|
||||
|
||||
|
||||
static FILE *fp = NULL;
|
||||
sprintf(name, "crashdump-%d.txt", (int)time(NULL));
|
||||
if (state != 0)
|
||||
@@ -643,7 +650,11 @@ int main(int argc, char *argv[])
|
||||
console_printf(Console_Default, "S");
|
||||
signal(SIGTERM, signalhandler);
|
||||
console_printf(Console_Default, "T]\n");
|
||||
|
||||
|
||||
#ifdef RUN_COVERAGE
|
||||
signal(SIGALRM, alarmHandler);
|
||||
#endif
|
||||
|
||||
/* */
|
||||
console_printf(Console_Default, "Initialize memory...\t\t");
|
||||
InitMemory();
|
||||
@@ -957,6 +968,10 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
|
||||
gettimeofday(&timeStart, NULL);
|
||||
|
||||
#ifdef RUN_COVERAGE
|
||||
alarm(1 * 60); /* Run for 1 minutes */
|
||||
#endif
|
||||
|
||||
while(!WantClosing)
|
||||
{
|
||||
|
||||
@@ -10,4 +10,9 @@
|
||||
# $Revision$
|
||||
|
||||
file(GLOB mappers_list mappers/*.c)
|
||||
add_library(mappermanager utils.c manager.c ${mappers_list} )
|
||||
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/mappersmanager/manager.c src/mappersmanager/utils.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_library(mappermanager utils.c manager.c ${mappers_list} )
|
||||
|
||||
68
src/mappersmanager/mappers/unrom512.c
Executable file
68
src/mappersmanager/mappers/unrom512.c
Executable file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* UNROM Mapper - The TI-NESulator Project
|
||||
* unrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ppu/ppu.h>
|
||||
#include "unrom512.h"
|
||||
|
||||
static byte mirroring_set;
|
||||
static byte loaded_vbank;
|
||||
static byte loaded_pbank;
|
||||
static void unrom512_applyValues()
|
||||
{
|
||||
/*if (mirroring_set)
|
||||
{
|
||||
ppu_setMirroring(PPU);
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu_setMirroring(PPU_MIRROR_VERTICAL);
|
||||
}*/
|
||||
|
||||
//set_vrom_bank_8k(0x0000, loaded_vbank);
|
||||
set_prom_bank_16k(0x8000, loaded_pbank);
|
||||
}
|
||||
|
||||
static void unrom512_MapperWriteHook(byte Addr, byte Value)
|
||||
{
|
||||
mirroring_set = (Value >> 7) & 0x01;
|
||||
loaded_vbank = (Value >> 5) & 0x03;
|
||||
loaded_pbank = (Value ) & 0x1F;
|
||||
|
||||
unrom512_applyValues();
|
||||
}
|
||||
|
||||
int unrom512_InitMapper(NesCart * cart)
|
||||
{
|
||||
int i;
|
||||
|
||||
loaded_vbank = 0;
|
||||
loaded_pbank = 0;
|
||||
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
|
||||
|
||||
unrom512_applyValues();
|
||||
|
||||
/* Register the write hook */
|
||||
for (i = 0x80; i < 0x100; i++)
|
||||
{
|
||||
set_page_wr_hook(i, unrom512_MapperWriteHook);
|
||||
set_page_writeable(i, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unrom512_MapperDump(FILE *fp)
|
||||
{
|
||||
fprintf(fp,"unrom512: vbank:%d pbank:%d\n", loaded_vbank, loaded_pbank);
|
||||
}
|
||||
19
src/mappersmanager/mappers/unrom512.h
Executable file
19
src/mappersmanager/mappers/unrom512.h
Executable file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* UNROM Mapper - The TI-NESulator Project
|
||||
* unrom.h
|
||||
*
|
||||
* Created by Manoel TRAPIER.
|
||||
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
|
||||
#define __TINES_MAPPERS__
|
||||
#include <mappers/manager.h>
|
||||
|
||||
int unrom512_InitMapper(NesCart * cart);
|
||||
void unrom512_MapperDump(FILE *fp);
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "mappers/unrom.h"
|
||||
#include "mappers/cnrom.h"
|
||||
|
||||
#include "mappers/unrom512.h"
|
||||
|
||||
#include "mappers/iremh3001.h"
|
||||
|
||||
#include "mappers/mmc1.h"
|
||||
@@ -32,7 +34,9 @@ Mapper Mappers[] = {
|
||||
|
||||
{ 1 , "MMC1", mmc1_InitMapper, norom_MapperIRQ, mmc1_MapperDump },
|
||||
{ 4 , "MMC3", mmc3_InitMapper, mmc3_MapperIRQ, mmc3_MapperDump },
|
||||
{ 10, "MMC4", mmc4_InitMapper, norom_MapperIRQ, mmc4_MapperDump },
|
||||
{ 10, "MMC4", mmc4_InitMapper, norom_MapperIRQ, mmc4_MapperDump },
|
||||
|
||||
{ 30, "UNROM512", unrom512_InitMapper, norom_MapperIRQ, unrom512_MapperDump },
|
||||
|
||||
{ 65, "Irem H3001", iremh3001_InitMapper, iremh3001_MapperIRQ, iremh3001_MapperDump },
|
||||
|
||||
|
||||
@@ -9,4 +9,8 @@
|
||||
# $HeadURL$
|
||||
# $Revision$
|
||||
|
||||
add_library(memorymanager memory.c)
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/memorymanager/memory.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_library(memorymanager memory.c)
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
# $HeadURL$
|
||||
# $Revision$
|
||||
|
||||
add_library(oslib loadfile.c graphics.c sound.c io.c)
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/os/unix/loadfile.c src/os/unix/graphics_dummy.c src/os/unix/sound.c src/os/unix/io.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||
add_library(oslib loadfile.c graphics_dummy.c sound.c io.c)
|
||||
else()
|
||||
add_library(oslib loadfile.c graphics.c sound.c io.c)
|
||||
endif()
|
||||
|
||||
target_link_libraries(oslib glfw ${OPENGL_glu_LIBRARY})
|
||||
target_link_libraries(oslib glfw ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#include <os_dependent.h>
|
||||
|
||||
#define GLFW_INCLUDE_GLEXT
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <OpenGL/glext.h>
|
||||
|
||||
#include <palette.h>
|
||||
|
||||
@@ -43,10 +43,6 @@ struct GLWindow_t
|
||||
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)
|
||||
@@ -63,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);
|
||||
@@ -104,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);
|
||||
@@ -140,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);
|
||||
}
|
||||
|
||||
@@ -169,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)
|
||||
{
|
||||
@@ -178,12 +178,14 @@ 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();
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g->windows);
|
||||
|
||||
138
src/os/unix/graphics_dummy.c
Normal file
138
src/os/unix/graphics_dummy.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Graphic Manager - The TI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <os_dependent.h>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
//#include <OpenGL/glext.h>
|
||||
|
||||
#include <palette.h>
|
||||
|
||||
typedef struct GLWindow_t GLWindow;
|
||||
|
||||
struct KeyArray
|
||||
{
|
||||
unsigned char lastState;
|
||||
unsigned char curState;
|
||||
unsigned char debounced;
|
||||
GLFWwindow* window;
|
||||
};
|
||||
|
||||
struct GLWindow_t
|
||||
{
|
||||
struct KeyArray keyArray[512];
|
||||
GLFWwindow* windows;
|
||||
unsigned char *videoMemory;
|
||||
GLint videoTexture;
|
||||
int WIDTH;
|
||||
int HEIGHT;
|
||||
};
|
||||
|
||||
#ifndef GL_TEXTURE_RECTANGLE_EXT
|
||||
#define GL_TEXTURE_RECTANGLE_EXT GL_TEXTURE_RECTANGLE_NV
|
||||
#endif
|
||||
|
||||
void GLWindowInitEx(GLWindow *g, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void GLWindowInit(GLWindow *g)
|
||||
{
|
||||
}
|
||||
|
||||
void ShowScreen(GLWindow *g, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void setupGL(GLWindow *g, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void restoreGL(GLWindow *g, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||
{
|
||||
}
|
||||
|
||||
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void initDisplay(GLWindow *g)
|
||||
{
|
||||
}
|
||||
|
||||
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
|
||||
{
|
||||
}
|
||||
|
||||
void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||
{
|
||||
}
|
||||
|
||||
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||
{
|
||||
}
|
||||
|
||||
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||
{
|
||||
}
|
||||
|
||||
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||
{
|
||||
}
|
||||
|
||||
void clearScreen(GLWindow *g)
|
||||
{
|
||||
}
|
||||
|
||||
void updateScreen(GLWindow *g)
|
||||
{
|
||||
}
|
||||
|
||||
void updateScreenAndWait(GLWindow *g)
|
||||
{
|
||||
}
|
||||
|
||||
int graphics_init()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graphics_drawpixel(long x, long y, long color)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graphics_blit(long x, long y, long w, long h)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getKeyStatus(int key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -40,11 +40,10 @@ int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||
|
||||
int console_printf(const ConsoleLevel level, const char *format, ...)
|
||||
{
|
||||
int ret = 0;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
ret = console_vprintf(level, format, ap);
|
||||
console_vprintf(level, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
return 0;
|
||||
@@ -58,4 +57,4 @@ int console_printf_d(const char *format, ...)
|
||||
console_vprintf (Console_Debug, format, ap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,10 @@ void *LoadFilePtr(char * filename)
|
||||
|
||||
close(fd);
|
||||
|
||||
if ( RetPtr == MAP_FAILED )
|
||||
{
|
||||
RetPtr = NULL;
|
||||
}
|
||||
|
||||
return RetPtr;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
# TI-NES CMake
|
||||
#
|
||||
# Created by Manoel TRAPIER.
|
||||
# Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
# Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
#
|
||||
# $LastChangedDate$
|
||||
# $Author$
|
||||
# $HeadURL$
|
||||
# $Revision$
|
||||
|
||||
add_library(oslib loadfile.c)
|
||||
add_library(oslib loadfile.c graphics.c sound.c io.c)
|
||||
|
||||
target_link_libraries(oslib glfw ${OPENGL_glu_LIBRARY})
|
||||
436
src/os/win32/graphics.c
Normal file
436
src/os/win32/graphics.c
Normal file
@@ -0,0 +1,436 @@
|
||||
/*
|
||||
* Graphic Manager - The TI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <os_dependent.h>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <OpenGL/glext.h>
|
||||
|
||||
#include <palette.h>
|
||||
|
||||
typedef struct GLWindow_t GLWindow;
|
||||
|
||||
struct KeyArray
|
||||
{
|
||||
unsigned char lastState;
|
||||
unsigned char curState;
|
||||
unsigned char debounced;
|
||||
GLFWwindow* window;
|
||||
};
|
||||
|
||||
struct GLWindow_t
|
||||
{
|
||||
struct KeyArray keyArray[512];
|
||||
GLFWwindow* windows;
|
||||
unsigned char *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)
|
||||
{
|
||||
g->WIDTH = w;
|
||||
g->HEIGHT = h;
|
||||
g->videoTexture = window_num++;
|
||||
}
|
||||
|
||||
void GLWindowInit(GLWindow *g)
|
||||
{
|
||||
GLWindowInitEx(g, 100, 100);
|
||||
}
|
||||
|
||||
void ShowScreen(GLWindow *g, int w, int h)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 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);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(-1.0f,1.0f);
|
||||
|
||||
glTexCoord2f(0.0f, h);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
|
||||
glTexCoord2f(w, h);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
|
||||
glTexCoord2f(w, 0.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
void setupGL(GLWindow *g, int w, int h)
|
||||
{
|
||||
g->videoMemory = (unsigned char*)malloc(w*h*sizeof(unsigned int));
|
||||
memset(g->videoMemory, 0,w*h*sizeof(unsigned int));
|
||||
//Tell OpenGL how to convert from coordinates to pixel values
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_EXT);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 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);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, w,
|
||||
h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void restoreGL(GLWindow *g, int w, int h)
|
||||
{
|
||||
//Tell OpenGL how to convert from coordinates to pixel values
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glClearColor(1.0f, 0.f, 1.0f, 1.0f);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_EXT);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
|
||||
{
|
||||
struct KeyArray *keyArray;
|
||||
|
||||
keyArray = (struct KeyArray*) glfwGetWindowUserPointer(window);
|
||||
|
||||
keyArray[key].lastState=keyArray[key].curState;
|
||||
if (action==GLFW_RELEASE)
|
||||
{
|
||||
keyArray[key].curState=GLFW_RELEASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyArray[key].curState=GLFW_PRESS;
|
||||
}
|
||||
keyArray[key].debounced |= (keyArray[key].lastState==GLFW_RELEASE)&&(keyArray[key].curState==GLFW_PRESS);
|
||||
keyArray[key].window = window;
|
||||
}
|
||||
|
||||
void sizeHandler(GLFWwindow* window,int xs,int ys)
|
||||
{
|
||||
glfwMakeContextCurrent(window);
|
||||
glViewport(0, 0, xs, ys);
|
||||
}
|
||||
|
||||
|
||||
void initDisplay(GLWindow *g)
|
||||
{
|
||||
int h = g->HEIGHT;
|
||||
int w = g->WIDTH;
|
||||
|
||||
/// Initialize GLFW
|
||||
glfwInit();
|
||||
|
||||
// Open screen OpenGL window
|
||||
if( !(g->windows=glfwCreateWindow( g->WIDTH, g->HEIGHT, "Main", NULL, NULL)) )
|
||||
{
|
||||
glfwTerminate();
|
||||
fprintf(stderr, "Window creation error...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g->windows);
|
||||
setupGL(g, g->WIDTH, g->HEIGHT);
|
||||
|
||||
glfwSwapInterval(0); // Disable VSYNC
|
||||
|
||||
glfwGetWindowSize(g->windows, &w, &h);
|
||||
|
||||
glfwSetWindowUserPointer(g->windows, g->keyArray);
|
||||
|
||||
glfwSetKeyCallback(g->windows, kbHandler);
|
||||
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
|
||||
return;
|
||||
|
||||
b = colour & 0xFF;
|
||||
g = (colour >> 8) & 0xFF;
|
||||
r = (colour >> 16) & 0xFF;
|
||||
a = (colour >> 24) & 0xFF;
|
||||
|
||||
gw->videoMemory[offset + 0] = a;
|
||||
gw->videoMemory[offset + 1] = r;
|
||||
gw->videoMemory[offset + 2] = g;
|
||||
gw->videoMemory[offset + 3] = b;
|
||||
}
|
||||
|
||||
void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
|
||||
{
|
||||
int d, dx, dy, aincr, bincr, xincr, yincr, x, y;
|
||||
if (abs(x1 - x0) < abs(y1 - y0))
|
||||
{
|
||||
/* parcours par l'axe vertical */
|
||||
if (y0 > y1)
|
||||
{
|
||||
drawLine(g, x1, y1, x0, y0, colour);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
xincr = x1 > x0 ? 1 : -1;
|
||||
dy = y1 - y0;
|
||||
dx = abs(x1 - x0);
|
||||
d = 2 * dx - dy;
|
||||
aincr = 2 * (dx - dy);
|
||||
bincr = 2 * dx;
|
||||
x = x0;
|
||||
y = y0;
|
||||
|
||||
drawPixel(g, x, y, colour);
|
||||
|
||||
for (y = y0+1; y <= y1; y++)
|
||||
{
|
||||
if (d >= 0)
|
||||
{
|
||||
x += xincr;
|
||||
d += aincr;
|
||||
}
|
||||
else
|
||||
{
|
||||
d += bincr;
|
||||
}
|
||||
|
||||
drawPixel(g, x, y, colour);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* parcours par l'axe horizontal */
|
||||
if (x0 > x1)
|
||||
{
|
||||
drawLine(g, x1, y1, x0, y0, colour);
|
||||
goto exit;
|
||||
}
|
||||
yincr = y1 > y0 ? 1 : -1;
|
||||
dx = x1 - x0;
|
||||
dy = abs(y1 - y0);
|
||||
d = 2 * dy - dx;
|
||||
aincr = 2 * (dy - dx);
|
||||
bincr = 2 * dy;
|
||||
x = x0;
|
||||
y = y0;
|
||||
|
||||
drawPixel(g, x, y, colour);
|
||||
|
||||
for (x = x0+1; x <= x1; ++x)
|
||||
{
|
||||
if (d >= 0)
|
||||
{
|
||||
y += yincr;
|
||||
d += aincr;
|
||||
}
|
||||
else
|
||||
{
|
||||
d += bincr;
|
||||
}
|
||||
|
||||
drawPixel(g, x, y, colour);
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
|
||||
{
|
||||
int f = 1 - radius;
|
||||
int ddF_x = 0;
|
||||
int ddF_y = -2 * radius;
|
||||
int x = 0;
|
||||
int y = radius;
|
||||
int pX, pY;
|
||||
|
||||
pX = xc; pY = yc + radius;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pY -= (2*radius);
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pY += radius; pX += radius;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX -= (2*radius);
|
||||
drawPixel(g, pX, pY, colour);
|
||||
|
||||
while(x < y)
|
||||
{
|
||||
if(f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x + 1;
|
||||
pX = xc+x ; pY = yc+y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-x ; pY = yc+y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc+x ; pY = yc-y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-x ; pY = yc-y;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc+y ; pY = yc+x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-y ; pY = yc+x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc+y ; pY = yc-x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
pX = xc-y ; pY = yc-x;
|
||||
drawPixel(g, pX, pY, colour);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||
{
|
||||
drawLine(g, x0 , y0 , x0 + w, y0 , colour);
|
||||
drawLine(g, x0 + w, y0 , x0 + w, y0 + h, colour);
|
||||
drawLine(g, x0 + w, y0 + h, x0 , y0 + h, colour);
|
||||
drawLine(g, x0 , y0 + h, x0 , y0 , colour);
|
||||
}
|
||||
|
||||
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < h; i++)
|
||||
drawLine(g, x0, y0+i, x0+w, y0+i, colour);
|
||||
}
|
||||
|
||||
void clearScreen(GLWindow *g)
|
||||
{
|
||||
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
||||
}
|
||||
|
||||
void updateScreen(GLWindow *g)
|
||||
{
|
||||
/*Update windows code */
|
||||
glfwMakeContextCurrent(g->windows);
|
||||
ShowScreen(g, g->WIDTH, g->HEIGHT);
|
||||
glfwSwapBuffers(g->windows);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
void updateScreenAndWait(GLWindow *g)
|
||||
{
|
||||
while (glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_PRESS)
|
||||
{
|
||||
updateScreen(g);
|
||||
|
||||
glfwPollEvents();
|
||||
}
|
||||
while(glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_RELEASE)
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
GLWindow mainWindow;
|
||||
|
||||
int graphics_init()
|
||||
{
|
||||
GLWindowInitEx(&mainWindow, 256, 240);
|
||||
initDisplay(&mainWindow);
|
||||
clearScreen(&mainWindow);
|
||||
updateScreen(&mainWindow);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned long getColour(long color)
|
||||
{
|
||||
Palette *pal = &basicPalette[color];
|
||||
uint8_t r, g, b, a;
|
||||
r = pal->r;
|
||||
b = pal->b;
|
||||
g = pal->g;
|
||||
a = 255;//pal->a;
|
||||
return (b << 24) | (g << 16) | (r << 8) | a;
|
||||
}
|
||||
|
||||
int graphics_drawpixel(long x, long y, long color)
|
||||
{
|
||||
drawPixel(&mainWindow, x, y, getColour(color));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graphics_drawline(long x, long y, long x1, long y1, long color)
|
||||
{
|
||||
drawLine(&mainWindow, x, y, x1, y1, getColour(color));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graphics_blit(long x, long y, long w, long h)
|
||||
{
|
||||
updateScreen(&mainWindow);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getKeyStatus(int key)
|
||||
{
|
||||
return mainWindow.keyArray[key].curState;
|
||||
}
|
||||
61
src/os/win32/io.c
Normal file
61
src/os/win32/io.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* IO Manager - The TI-NESulator Project
|
||||
* os/macos/graphics.c
|
||||
*
|
||||
* Created by Manoël Trapier on 04/01/09.
|
||||
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <os_dependent.h>
|
||||
|
||||
char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D'};
|
||||
|
||||
ConsoleLevel console_ActualLevel = Console_Default;
|
||||
|
||||
/* Actually nothing to do */
|
||||
int console_init(ConsoleLevel DefaultLevel)
|
||||
{
|
||||
console_ActualLevel = DefaultLevel;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Actually a simple printf with levels */
|
||||
int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
|
||||
{
|
||||
if (console_ActualLevel >= level)
|
||||
vprintf(format, ap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int console_printf(const ConsoleLevel level, const char *format, ...)
|
||||
{
|
||||
int ret = 0;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
ret = console_vprintf(level, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int console_printf_d(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
console_vprintf (Console_Debug, format, ap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
34
src/os/win32/loadfile.c
Normal file
34
src/os/win32/loadfile.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2016 986-Studio. All rights reserved.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
/* Map a file in memory */
|
||||
void *LoadFilePtr(char * filename)
|
||||
{
|
||||
int fd;
|
||||
void *RetPtr = NULL;
|
||||
struct stat FileStat;
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
|
||||
fstat(fd, &FileStat);
|
||||
|
||||
RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
|
||||
close(fd);
|
||||
|
||||
return RetPtr;
|
||||
}
|
||||
0
src/os/win32/sound.c
Normal file
0
src/os/win32/sound.c
Normal file
@@ -10,4 +10,9 @@
|
||||
# $Revision$
|
||||
|
||||
file(GLOB plugins_list plugins/*.c)
|
||||
add_library(pluginsmanager manager.c ${plugins_list})
|
||||
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/pluginsmanager/manager.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_library(pluginsmanager manager.c ${plugins_list})
|
||||
|
||||
@@ -10,4 +10,10 @@
|
||||
# $Revision$
|
||||
|
||||
file(GLOB ppu_debug_list debug/*.c)
|
||||
add_library(ppu ppu.c ppu.memory.c ${ppu_debug_list})
|
||||
|
||||
if (COVERALLS)
|
||||
set(COVERAGE_SRCS src/ppu/ppu.c src/ppu/ppu.memory.c ${COVERAGE_SRCS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
|
||||
add_library(ppu ppu.c ppu.memory.c ${ppu_debug_list})
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if 0
|
||||
/* Allegro includes */
|
||||
#ifdef __APPLE__
|
||||
#define USE_CONSOLE
|
||||
@@ -367,3 +368,4 @@ void ppu_dumpPalette(int x, int y)
|
||||
rectfill(Buffer, x + 91 + (i % 4) * 20, y + 21 +(i / 4) * 20, x + 91 + (i % 4) * 20 + 20, y + 21 +(i / 4) * 20 + 20, ppu_readMemory(0x3F, i+0x10));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
extern int VBLANK_TIME;
|
||||
|
||||
volatile extern int frame;
|
||||
volatile extern unsigned long IPS, FPS;
|
||||
extern volatile int frame;
|
||||
extern volatile unsigned long IPS, FPS;
|
||||
|
||||
extern unsigned long ColorPalette[9 * 63];
|
||||
extern short IRQScanHit;
|
||||
|
||||
Reference in New Issue
Block a user