Merge remote-tracking branch 'origin/master'

# Conflicts:
#	CMakeLists.txt
#	src/CMakeLists.txt
#	src/NESCarts.c
#	src/os/unix/graphics.c
#	src/ppu/debug/ppu.debug.c
This commit is contained in:
Godzil 2018-01-30 16:16:33 +00:00
commit 05f17740fd
19 changed files with 291 additions and 41 deletions

3
.gitmodules vendored
View File

@ -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
View 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)

View File

@ -20,6 +20,9 @@ add_subdirectory("external/glfw")
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
link_libraries(${OPENGL_gl_LIBRARY})
if (COVERALLS)
enable_testing()
endif (COVERALLS)
add_subdirectory (src)

View File

@ -1,7 +1,9 @@
TI-NESulator
============
This is a cleaned version of the TI-NESulator repository (all data has been removed)
[![Coverage Status](https://coveralls.io/repos/github/Godzil/TI-NESulator/badge.svg?branch=master)](https://coveralls.io/github/Godzil/TI-NESulator?branch=master) [![codecov](https://codecov.io/gh/Godzil/TI-NESulator/branch/master/graph/badge.svg)](https://codecov.io/gh/Godzil/TI-NESulator) [![travis](https://travis-ci.org/Godzil/TI-NESulator.svg?branch=master)](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

Binary file not shown.

1
external/coveralls-cmake vendored Submodule

@ -0,0 +1 @@
Subproject commit e37d5b8674dab235185b07ad9208c88d84f81823

View File

@ -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,6 +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_compile_options(tines PRIVATE -pthread)
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)

View File

@ -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)

View File

@ -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
@ -257,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)
@ -642,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();
@ -956,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)
{

View File

@ -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} )

View File

@ -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)

View File

@ -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})

View File

@ -18,12 +18,8 @@
#include <os_dependent.h>
#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
#ifdef __MACOSX__
#include <OpenGL/glext.h>
#else
#include <GL/glext.h>
#endif
#include <palette.h>
@ -47,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)
@ -67,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);
@ -108,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);
@ -144,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);
}
@ -223,7 +215,6 @@ void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
r = (colour >> 16) & 0xFF;
a = (colour >> 24) & 0xFF;
gw->videoMemory[offset + 0] = a;
gw->videoMemory[offset + 1] = r;
gw->videoMemory[offset + 2] = g;

View 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;
}

View File

@ -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 ret;
@ -58,4 +57,4 @@ int console_printf_d(const char *format, ...)
console_vprintf (Console_Debug, format, ap);
return 0;
}
}

View File

@ -30,5 +30,10 @@ void *LoadFilePtr(char * filename)
close(fd);
if ( RetPtr == MAP_FAILED )
{
RetPtr = NULL;
}
return RetPtr;
}

View 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})

View File

@ -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})

View File

@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#if 0
/* Allegro includes */
#ifdef __APPLE__
@ -21,7 +22,7 @@
#include <Allegro/allegro.h>
#else
#define USE_CONSOLE
//#include <allegro.h>
#include <allegro.h>
#endif
#define __TINES_PPU_INTERNAL__
@ -367,4 +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
#endif