Compare commits

..

1 Commits

Author SHA1 Message Date
Godzil
844a209027 First tentative support.
Need first to make it to build!
2020-01-14 18:55:46 +00:00
21 changed files with 396 additions and 366 deletions

View File

@ -1,4 +1,11 @@
dist: trusty
language: c
os:
- linux
- osx
#matrix:
# allow_failures:
# - os: osx
addons:
apt:
@ -7,76 +14,40 @@ addons:
- curl
- xorg-dev
- libglu1-mesa-dev
# sonarcloud:
# organisation: "godzil-github"
# token: ${SONARCLOUD_TOKEN}
compiler:
- clang
- gcc
script:
- mkdir build
- cd build
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=OFF -DCMAKE_BUILD_TYPE=Release ..
- cmake --build .
- cd ..
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir sonar; cd sonar; cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=OFF -DCMAKE_BUILD_TYPE=Release ..; fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean ; fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then build-wrapper-linux-x86-64 --out-dir bw-output cmake --build . ; fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd .. ; fi
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sonar-scanner -Dsonar.login=$SONARCLOUD_TOKEN; fi
- mkdir coverage
- cd coverage
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build .
- cmake --build . --target coveralls
cache:
directories:
- '$HOME/.sonar/cache'
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install glew; fi
jobs:
include:
- os: linux
dist: bionic
arch: amd64
compiler: gcc
install: true
- os: linux
dist: bionic
arch: amd64
compiler: clang
- os: linux
dist: focal
arch: amd64
compiler: gcc
- os: linux
dist: focal
arch: amd64
compiler: clang
- os: osx
compiler: clang
osx_image: xcode12.2
- os: linux
dist: focal
arch: arm64
compiler: gcc
- os: osx
compiler: clang
osx_image: xcode10.3
- os: osx
compiler: clang
osx_image: xcode11.6
- os: osx
compiler: clang
osx_image: xcode12
- stage: "Coverage"
os: linux
dist: bionic
arch: amd64
compiler: gcc
script:
- mkdir coverage
- cd coverage
- cmake -DUSE_ALLEGRO=OFF -DUSE_PROFILING=OFF -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build .
- cmake --build . --target coveralls
after_success:
- bash <(curl -s https://codecov.io/bash)
allow_failures:
- os: linux
arch: arm64
- os: osx
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -4,27 +4,31 @@
# Created by Manoel TRAPIER.
# Copyright (c) 2002-2019 986-Studio.
#
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.1)
project (peTI-NESulator)
# External cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/cmake ${CMAKE_MODULE_PATH})
# Include GLFW
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory("external/glfw")
find_package(OpenGL REQUIRED)
if (USE_GLFW)
message("Coucou ${USE_GLFW}")
# Include GLFW
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory("external/glfw")
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
endif (USE_GLFW)
include_directories(${OPENGL_INCLUDE_DIR})
# Include PortAudio
set(PA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(PA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(PA_ENABLE_DEBUG_OUTPUT OFF CACHE BOOL "" FORCE)
add_subdirectory("external/portaudio")
if (USE_PORTAUDIO)
# Include PortAudio
set(PA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(PA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(PA_ENABLE_DEBUG_OUTPUT OFF CACHE BOOL "" FORCE)
add_subdirectory("external/portaudio")
endif (USE_PORTAUDIO)
if (COVERALLS)
enable_testing()

View File

@ -15,25 +15,17 @@ set(DETECT_BUS_CONFLICT OFF CACHE BOOL "Activate the bus conflit detector? (Coul
set(USE_EFENCE OFF CACHE BOOL "Use electricfence memory debugger?")
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)
option(WARN_AS_ERROR "Enable warning as error" OFF)
##########################
# Link & Compile flags
##########################
set(COMP_FLAGS "-march=native -Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Wno-write-strings ${PLATFORM_FLAGS}")
if (WARN_AS_ERROR)
set(COMP_FLAGS "${COMP_FLAGS} -Werror")
endif()
#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_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result ${PLATFORM_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result ${PLATFORM_FLAGS}")
set(CMAKE_C_FLAGS ${COMP_FLAGS})
set(CMAKE_CXX_FLAGS ${COMP_FLAGS})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake)
add_executable(petines main.c paddle.c NESCarts.c)
@ -75,6 +67,20 @@ endif ()
include_directories(include)
set(OS_TARGET "UNIX" CACHE STRING "Select target to build against")
set_property(CACHE OS_TARGET PROPERTY STRINGS TI68K WIN32 UNIX 32BLIT)
if ("${OS_TARGET}" STREQUAL "TI68K")
add_subdirectory(os/ti68k)
elseif ("${OS_TARGET}" STREQUAL "WIN32")
add_subdirectory(os/win32)
elseif ("${OS_TARGET}" STREQUAL "UNIX")
add_subdirectory(os/unix)
elseif ("${OS_TARGET}" STREQUAL "32BLIT")
add_subdirectory(os/32blit)
endif ()
add_subdirectory(apu)
add_subdirectory(corecpu)
add_subdirectory(mappersmanager)
@ -83,14 +89,9 @@ add_subdirectory(pluginsmanager)
add_subdirectory(ppu)
if (TARGET_TI68k)
add_subdirectory(os/ti68k)
elseif (WIN32)
add_subdirectory(os/win32)
else (TARGET_TI68k)
add_subdirectory(os/unix)
endif (TARGET_TI68k)
if ( (NOT ${OS_TARGET} STREQUAL "TI68K") AND (NOT ${OS_TARGET} STREQUAL "32BLIT") )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake)
endif ()
#find_library(PTHREADLIB pthread)
if (COVERALLS)

View File

@ -5,4 +5,8 @@
# Copyright (c) 2002-2019 986-Studio.
#
add_library(apu apu.c apu.c)
target_link_libraries(apu portaudio_static)
if (USE_PORTAUDIO)
target_link_libraries(apu portaudio_static)
else()
target_link_libraries(apu)
endif()

View File

@ -11,18 +11,13 @@
#define OS_DEPENDENT_H
#include <stdint.h>
#include "text.h"
/* File related functions */
/* Graphics related functions */
int graphics_init();
int graphics_drawpixel(long x, long y, long color);
int graphics_blit(long x, long y, long w, long h);
int graphics_drawline(uint32_t x, uint32_t y, uint32_t x1, uint32_t y1, uint32_t colour);
int graphics_drawRect(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour);
int graphics_drawFillrect(int x0, int y0, int w, int h, uint32_t colour);
int graphics_getScreenSize(int *w, int *h);
int graphics_drawline(long x, long y, long x1, long y1, long color);
void vsync(void);
typedef struct Palette_t
@ -52,15 +47,4 @@ int console_init(ConsoleLevel DefaultLevel);
int console_printf(const ConsoleLevel level, const char *format, ...);
int console_printf_d(const char *format, ...);
#define KEY_ENTER (257)
#define KEY_LEFT (263)
#define KEY_RIGHT (262)
#define KEY_UP (265)
#define KEY_DOWN (264)
//#define KEY_ENTER 13
#endif /* OS_DEPENDENT_H */

View File

@ -26,7 +26,7 @@ int plugin_remove_keypressHandler(uint8_t key, PluginKeypress);
#else /* __TINES_PLUGINS__ */
/* Available functions outside of plugins */
int plugin_keypress();
int plugin_keypress(uint8_t key);
/* Real Prototype: TBD */
void plugin_list();

View File

@ -1,58 +0,0 @@
/*
* FbLib graphic library
*
* Created by Manoël TRAPIER.
* Copyright (c) 2003-2019 986-Studio. All rights reserved.
*
*/
#ifndef _FBLIB_INCLUDE_TEXT_H
#define _FBLIB_INCLUDE_TEXT_H
typedef struct FBLibFont
{
char *name; /* Font name. */
int height; /* Height in pixels. */
int index_mask; /* ((1 << N) - 1). */
int *offset; /* (1 << N) offsets into index. */
int *index;
uint32_t *content;
//void *private;
} FBLibFont;
/* ? */
FBLibFont *load_psf(char *filename);
void graphics_text_line(int x, int y, int w, int charw, uint32_t color, int valign, void *font, char *text);
int graphics_text_ex(int x, int y, int w, int h,
void *font,
uint32_t bgcolor, uint32_t fgcolor,
char valign, char halign,
uint16_t options,
void *format, ...);
void graphics_get_text_size(int *width, int *height,
const FBLibFont *font,
const char *text);
void graphics_draw_text (int x, int y,
uint32_t colour,
const FBLibFont *font,
const char *text);
#define TEXT_VALIGN_LEFT (1)
#define TEXT_VALIGN_RIGHT (2)
#define TEXT_VALIGN_CENTER (3)
#define TEXT_HALIGN_TOP (1)
#define TEXT_HALIGN_CENTER (2)
#define TEXT_HALIGN_BOTTOM (3)
#define TEXT_OPT_WORDWRAP (1<<0)
#define TEXT_DEFAULTFONT ((void*)(1))
#define TEXT_SMALLFONT ((void*)(2))
#define TEXT_LARGEFONT ((void*)(3))
#endif /* _FBLIB_INCLUDE_TEXT_H */

View File

@ -740,12 +740,12 @@ int main(int argc, char *argv[])
ppu_setMirroring((Cart->Flags & iNES_MIRROR) ? PPU_MIRROR_VERTICAL : PPU_MIRROR_HORIZTAL);
}
//console_printf(Console_Default, "Init mapper...\n");
console_printf(Console_Default, "Init mapper...\t\t\t");
if (mapper_init(Cart) == -1)
{
return -1;
}
//console_printf(Console_Default, "[ OK ]\n");
console_printf(Console_Default, "[ OK ]\n");
// set_palette(basicPalette);
@ -933,7 +933,7 @@ void Loop6502(quick6502_cpu *R)
quick6502_reset(R);
}
plugin_keypress();
// plugin_keypress(skey);
if (cpuSignal != 0)
{

View File

@ -0,0 +1,17 @@
#
# peTI-NESulator CMake
#
# Created by Manoël Trapier.
# Copyright (c) 2002-2019 986-Studio.
#
set(USE_GLFW OFF BOOL CACHE INTERNAL "USE_GLFW")
set(USE_PORTAUDIO OFF BOOL CACHE INTERNAL "USE_PORTAUDIO")
set(PATH_32BLIT "../32blit" CACHE PATH "Path to 32Blit SDK")
set(CMAKE_TOOLCHAIN_FILE "../../"${PATH_32BLIT}/32blit.toolchain)
include("../../"${PATH_32BLIT}/32blit.cmake)
add_library(oslib loadfile.c graphics.c sound.c io.c text.c)
target_link_libraries(oslib)

86
src/os/32blit/graphics.c Normal file
View File

@ -0,0 +1,86 @@
/*
* Graphic Manager - The peTI-NESulator Project
* os/macos/graphics.c
*
* Created by Manoël Trapier on 08/05/08.
* Copyright (c) 2002-2019 986-Studio.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <os_dependent.h>
#include <palette.h>
int graphics_init()
{
return 0;
}
static uint32_t getColour(long color)
{
Palette *pal = &basicPalette[color];
uint8_t r, g, b, a;
r = pal->r << 2;
b = pal->b << 2;
g = pal->g << 2;
a = 255;//pal->a;
return (b << 24) | (g << 16) | (r << 8) | a;
}
int graphics_getScreenSize(int *w, int *h)
{
return 0;
}
int graphics_drawRect(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour)
{
return getColour(colour);
}
int graphics_drawFillrect(int x0, int y0, int w, int h, uint32_t colour)
{
return 0;
}
int graphics_drawpixel(long x, long y, long color)
{
return 0;
}
int graphics_drawCircle(int xc, int yc, int radius, uint32_t colour)
{
return 0;
}
int graphics_drawline(uint32_t x, uint32_t y, uint32_t x1, uint32_t y1, uint32_t colour)
{
return 0;
}
int graphics_blit(long x, long y, long w, long h)
{
return 0;
}
int getKeyStatus(int key)
{
return 0;
}
/* Sync with 60Hz (or try to) */
void vsync(void)
{
}

59
src/os/32blit/io.c Normal file
View File

@ -0,0 +1,59 @@
/*
* IO Manager - The peTI-NESulator Project
* os/macos/graphics.c
*
* Created by Manoël Trapier on 04/01/09.
* Copyright (c) 2002-2019 986-Studio.
*
*/
#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, ...)
{
va_list ap;
va_start(ap, format);
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);
va_end(ap);
return 0;
}

39
src/os/32blit/loadfile.c Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2002-2019 986-Studio.
*/
#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;
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);
if (RetPtr == MAP_FAILED)
{
RetPtr = NULL;
}
return RetPtr;
}

0
src/os/32blit/sound.c Normal file
View File

View File

@ -4,6 +4,9 @@
# Created by Manoël Trapier.
# Copyright (c) 2002-2019 986-Studio.
#
set(USE_GLFW ON BOOL CACHE INTERNAL "USE_GLFW")
set(USE_PORTAUDIO ON BOOL CACHE INTERNAL "USE_PORTAUDIO")
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 text.c)

Binary file not shown.

View File

@ -158,8 +158,8 @@ void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
}
keyArray[key].debounced |= (keyArray[key].lastState == GLFW_RELEASE) && (keyArray[key].curState == GLFW_PRESS);
keyArray[key].window = window;
/*printf("key:%d, state:%d debounce:%d, laststate:%d\n", key, keyArray[key].curState,
keyArray[key].debounced, keyArray[key].lastState);*/
printf("key:%d, state:%d debounce:%d, laststate:%d\n", key, keyArray[key].curState,
keyArray[key].debounced, keyArray[key].lastState);
}
void sizeHandler(GLFWwindow *window, int xs, int ys)
@ -206,13 +206,13 @@ void initDisplay(GLWindow *g)
glfwSetWindowSizeCallback(g->windows, sizeHandler);
}
static void drawPixel(GLWindow *gw, uint32_t x, uint32_t y, uint32_t colour)
void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
{
uint8_t r, g, b, a;
uint32_t offset = (y * gw->WIDTH * 4U) + 4U * x;
if ((x > (uint32_t)gw->WIDTH) || (y > (uint32_t)gw->HEIGHT))
if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
{
return;
}
@ -228,14 +228,10 @@ static void drawPixel(GLWindow *gw, uint32_t x, uint32_t y, uint32_t colour)
gw->videoMemory[offset + 3] = b;
}
static void drawLine(GLWindow *g, int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t colour)
void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
{
printf("%s:%s(%p, %d, %d, %d, %d, %d) @ %d\n", __FILE__, __func__,
g, x0, y0, x1, y1, colour,
__LINE__);
int32_t d, dx, dy, aincr, bincr, xincr, yincr;
int32_t x, y;
if (abs((int32_t)x1 - x0) < abs((int32_t)y1 - y0))
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)
@ -246,9 +242,9 @@ static void drawLine(GLWindow *g, int32_t x0, int32_t y0, int32_t x1, int32_t y1
xincr = x1 > x0 ? 1 : -1;
dy = y1 - y0;
dx = abs((int32_t)x1 - x0);
dx = abs(x1 - x0);
d = 2 * dx - dy;
aincr = 2 * ((int32_t)dx - dy);
aincr = 2 * (dx - dy);
bincr = 2 * dx;
x = x0;
y = y0;
@ -281,7 +277,7 @@ static void drawLine(GLWindow *g, int32_t x0, int32_t y0, int32_t x1, int32_t y1
}
yincr = y1 > y0 ? 1 : -1;
dx = x1 - x0;
dy = abs((int32_t)y1 - y0);
dy = abs(y1 - y0);
d = 2 * dy - dx;
aincr = 2 * (dy - dx);
bincr = 2 * dy;
@ -310,7 +306,7 @@ exit:
return;
}
static void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
{
int f = 1 - radius;
int ddF_x = 0;
@ -368,24 +364,17 @@ static void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
}
}
static void drawRect(GLWindow *g, uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour)
void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
{
printf("%s:%s(%p, %d, %d, %d, %d, %d) @ %d\n", __FILE__, __func__,
g, x0, y0, w, h, colour,
__LINE__);
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);
}
static void drawFillrect(GLWindow *g, uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour)
void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
{
printf("%s:%s(%p, %d, %d, %d, %d, %d) @ %d\n", __FILE__, __func__,
g, x0, y0, w, h, colour,
__LINE__);
uint32_t i;
int i;
for (i = 0 ; i < h ; i++)
{
drawLine(g, x0, y0 + i, x0 + w, y0 + i, colour);
@ -399,7 +388,7 @@ void clearScreen(GLWindow *g)
void updateScreen(GLWindow *g)
{
/* Update windows code */
/*Update windows code */
glfwMakeContextCurrent(g->windows);
ShowScreen(g, g->WIDTH, g->HEIGHT);
glfwSwapBuffers(g->windows);
@ -442,49 +431,15 @@ static uint32_t getColour(long color)
return (b << 24) | (g << 16) | (r << 8) | a;
}
int graphics_getScreenSize(int *w, int *h)
{
*w = mainWindow.WIDTH;
*h = mainWindow.HEIGHT;
return 0;
}
int graphics_drawRect(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour)
{
printf("%s:%s(%d, %d, %d, %d, %d) @ %d\n", __FILE__, __func__,
x0, y0, w, h, colour,
__LINE__);
drawRect(&mainWindow, x0, y0, w, h, colour);
return 0;
}
int graphics_drawFillrect(int x0, int y0, int w, int h, uint32_t colour)
{
printf("%s:%s(%d, %d, %d, %d, %d) @ %d\n", __FILE__, __func__,
x0, y0, w, h, colour,
__LINE__);
drawFillrect(&mainWindow, x0, y0, w, h, colour);
return 0;
}
int graphics_drawpixel(long x, long y, long color)
{
drawPixel(&mainWindow, x, y, getColour(color));
return 0;
}
int graphics_drawCircle(int xc, int yc, int radius, uint32_t colour)
int graphics_drawline(long x, long y, long x1, long y1, long color)
{
drawCircle(&mainWindow, xc, yc, radius, colour);
return 0;
}
int graphics_drawline(uint32_t x, uint32_t y, uint32_t x1, uint32_t y1, uint32_t colour)
{
printf("%s:%s(%d, %d, %d, %d, %d) @ %d\n", __FILE__, __func__,
x, y, x1, y1, colour,
__LINE__);
drawLine(&mainWindow, x, y, x1, y1, getColour(colour));
drawLine(&mainWindow, x, y, x1, y1, getColour(color));
return 0;
}

View File

@ -120,28 +120,11 @@ int graphics_drawpixel(long x, long y, long color)
return 0;
}
int graphics_drawline(uint32_t x, uint32_t y, uint32_t x1, uint32_t y1, uint32_t colour)
int graphics_drawline(long x, long y, long x1, long y1, long color)
{
return 0;
}
int graphics_drawRect(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint32_t colour)
{
return 0;
}
int graphics_drawFillrect(int x0, int y0, int w, int h, uint32_t colour)
{
return 0;
}
int graphics_getScreenSize(int *w, int *h)
{
*w = 640;
*h = 320;
return 0;
}
int graphics_blit(long x, long y, long w, long h)
{
return 0;

View File

@ -55,11 +55,11 @@ int plugin_load(int id)
Plugin *ptr = &(Plugins[0]);
int i = id;
//console_printf(Console_Default, "%s(%d)", __func__, id);
console_printf(Console_Default, "%s(%d)", __func__, id);
for (; i > 1 && ptr->name != NULL ; i--)
{
//console_printf(Console_Default, "%d - %s\n", i, ptr->name);
console_printf(Console_Default, "%d - %s\n", i, ptr->name);
ptr++;
}
@ -131,15 +131,14 @@ int plugin_remove_keypressHandler(uint8_t key, PluginKeypress func)
/* Available functions outside of plugins */
int plugin_keypress()
int plugin_keypress(uint8_t key)
{
KeyHandler *ptr = keyHandlersList;
while (ptr != NULL)
{
if (getKeyStatus(ptr->key))
if (ptr->key == key)
{
console_printf(Console_Default, "Keyrrr [%d].....\n", ptr->key);
ptr->func();
}
ptr = ptr->next;

View File

@ -9,8 +9,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <os_dependent.h>
@ -19,11 +17,12 @@
#include <plugins/manager.h>
#undef __TINES_PLUGINS_
#include <os_dependent.h>
#include <memory/manager.h>
#include <types.h>
#if 0
typedef enum gg_States_
{
GG_S00_MAIN_STATE = 0,
@ -52,7 +51,7 @@ uint8_t gg_PatchedValue[10];
func_rdhook gg_rdhookPtr[10];
#define GG_RDHOOKPATCH(d) \
static uint8_t gg_RdHookPatch##d(uint8_t addr) \
uint8_t gg_RdHookPatch##d(uint8_t addr) \
{ \
if (addr == gg_PatchedAddr[d]) \
{ \
@ -68,22 +67,30 @@ static uint8_t gg_RdHookPatch##d(uint8_t addr) \
}
#define GG_MAX_PATCH 10
/* Defines the read hook patches */
/* Defines the rdhook patches */
GG_RDHOOKPATCH(0)
GG_RDHOOKPATCH(1)
GG_RDHOOKPATCH(2)
GG_RDHOOKPATCH(3)
GG_RDHOOKPATCH(4)
GG_RDHOOKPATCH(5)
GG_RDHOOKPATCH(6)
GG_RDHOOKPATCH(7)
GG_RDHOOKPATCH(8)
GG_RDHOOKPATCH(9)
void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
{
func_rdhook fptr;
func_rdhook cur_ptr;
if (id >= GG_MAX_PATCH)
{
@ -147,28 +154,30 @@ void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
break;
}
cur_ptr = get_page_rdhook(page);
if (cur_ptr != fptr)
{
set_page_rd_hook(page, fptr);
}
set_page_rd_hook(page, fptr);
}
/* Access to the bitmap Buffer */
extern BITMAP *Buffer;
BITMAP *gg_Buffer;
void MessageBox(char *title, char *msg)
{
int sc_w, sc_h;
int box_h, box_t, box_l, box_w;
sc_w = 640; //screen->w;
sc_h = 480; //screen->h;
sc_w = screen->w;
sc_h = screen->h;
/*gg_Buffer = create_bitmap(sc_w, sc_h);
gg_Buffer = create_bitmap(sc_w, sc_h);
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);*/
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
box_w = 0;// text_length(font, title) + 10;
box_w = text_length(font, title) + 10;
//box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
box_w += 15 * 2; /*sc_w/2;*/
box_h = 15 * 2 + 10;
@ -177,72 +186,70 @@ void MessageBox(char *title, char *msg)
box_t = (sc_h - box_h) / 2;
box_l = (sc_w - box_w) / 2;
graphics_drawFillrect(box_l, box_t, box_l + box_w, box_t + box_h, 60);
graphics_drawRect(box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
/* Display the title */
//textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
/* Display the message */
//textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
//blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
sleep(1000);
sleep(1);
//release_bitmap(gg_Buffer);
release_bitmap(gg_Buffer);
}
uint16_t SelectNumber(char *title, char *msg, uint8_t size)
{
//int sc_w, sc_h;
//int box_h;
int box_w;
//int box_t, box_l;
int sc_w, sc_h;
int box_h, box_t, box_l, box_w;
char valueText[10];
uint16_t value;
uint8_t digit = 0;
//sc_w = 640; //screen->w;
//sc_h = 480; //screen->h;
sc_w = screen->w;
sc_h = screen->h;
//gg_Buffer = create_bitmap(sc_w, sc_h);
gg_Buffer = create_bitmap(sc_w, sc_h);
//blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
//box_w = text_length(font, title) + 10;
box_w = text_length(font, title) + 10;
box_w = 0; //(box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
sprintf(valueText, "0000");
//box_w = (box_w > text_length(font, valueText)) ? box_w : text_length(font, msg);
box_w = (box_w > text_length(font, valueText)) ? box_w : text_length(font, msg);
box_w += 15 * 2; /*sc_w/2;*/
//box_h = 15 * 2 + 30;
box_h = 15 * 2 + 30;
/* Set the box center */
//box_t = (sc_h - box_h) / 2;
//box_l = (sc_w - box_w) / 2;
box_t = (sc_h - box_h) / 2;
box_l = (sc_w - box_w) / 2;
value = 0;
while (getKeyStatus(KEY_ENTER)) // ENTER
while (!key[KEY_ENTER])
{
//rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
//rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
/* Display the title */
//textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
/* Display the message */
//textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
if (size == 2)
{
@ -253,44 +260,44 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
sprintf(valueText, "%04X", value);
}
//textout_centre_ex(gg_Buffer, font, valueText, box_w / 2 + box_l, 15 + box_t + 2 + 10, 34, 60);
textout_centre_ex(gg_Buffer, font, valueText, box_w / 2 + box_l, 15 + box_t + 2 + 10, 34, 60);
switch (digit)
{
default:
case 0:
//textout_centre_ex(gg_Buffer, font, " ^", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
textout_centre_ex(gg_Buffer, font, " ^", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
break;
case 1:
//textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
break;
case 2:
//textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
textout_centre_ex(gg_Buffer, font, " ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
break;
case 3:
//textout_centre_ex(gg_Buffer, font, "^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
textout_centre_ex(gg_Buffer, font, "^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
break;
}
//blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
if (getKeyStatus(KEY_UP)) // UP
if (key[KEY_UP])
{
usleep(100000);
value += ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
value &= (size == 2) ? 0xFF : 0xFFFF;
}
if (getKeyStatus(KEY_DOWN)) // DOWN
if (key[KEY_DOWN])
{
usleep(100000);
value -= ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
value &= (size == 2) ? 0xFF : 0xFFFF;
}
if (getKeyStatus(KEY_RIGHT)) // RIGHT
if (key[KEY_RIGHT])
{
usleep(100000);
if (digit <= 0)
@ -303,7 +310,7 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
}
}
if (getKeyStatus(KEY_LEFT))
if (key[KEY_LEFT])
{
usleep(100000);
if (digit >= size - 1)
@ -317,8 +324,8 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
}
}
//release_bitmap(gg_Buffer);
while (getKeyStatus(KEY_ENTER))
release_bitmap(gg_Buffer);
while (key[KEY_ENTER])
{
}
return value;
@ -331,27 +338,20 @@ int DispMenu(int itemc, char *itemv[], char *title)
int selection = 0;
int i;
int sc_w, sc_h;
int32_t box_h, box_t, box_l, box_w;
int32_t text_h;
int box_h, box_t, box_l, box_w;
graphics_getScreenSize(&sc_w, &sc_h);
sc_w = screen->w;
sc_h = screen->h;
//gg_Buffer = create_bitmap(sc_w, sc_h);
gg_Buffer = create_bitmap(sc_w, sc_h);
//blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
graphics_get_text_size(&box_w, &text_h, NULL, title);
box_w += 10;
blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
box_w = text_length(font, title) + 10;
for (i = 0 ; i < itemc ; i++)
{
int32_t tmp;
graphics_get_text_size(&tmp, NULL, NULL, itemv[i]);
if (box_w < tmp)
{
box_w = tmp;
}
box_w = (box_w > text_length(font, itemv[i])) ? box_w : text_length(font, itemv[i]);
}
box_w += 15 * 2; /*sc_w/2;*/
@ -362,51 +362,36 @@ int DispMenu(int itemc, char *itemv[], char *title)
box_l = (sc_w - box_w) / 2;
while (!getKeyStatus(KEY_ENTER))
while (!key[KEY_ENTER])
{
/* Draw the box and highlight the selected item */
int i;
for (i = 0; i < box_h; i++)
{
graphics_drawline(box_l, box_t+i, box_w, box_t + i, 1);
}
graphics_drawline(5, 121, 251, 121, 41);
//graphics_drawFillrect(box_l, box_t, box_w, box_h, 5);
//graphics_drawRect(box_l + 5, box_t + 5, box_w - 5, box_h - 5, 1);
rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
/* Display the title */
graphics_text_ex(box_l, box_t + 2, box_w, text_h,
NULL,
34, 60,
TEXT_VALIGN_CENTER, TEXT_HALIGN_CENTER,
0,
title);
//textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
/* Display the highlight item */
//graphics_drawFillrect(box_l + 15, 15 + box_t + (selection * 10), box_l + box_w - 15,
// 15 + box_t + (selection * 10) + 10, 34);
graphics_draw_text(box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60, NULL, itemv[selection]);
//textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60,
// 34);
rectfill(gg_Buffer, box_l + 15, 15 + box_t + (selection * 10), box_l + box_w - 15,
15 + box_t + (selection * 10) + 10, 34);
textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60,
34);
/* Display other items */
for (i = 0 ; i < itemc ; i++)
{
if (i != selection)
{
//textout_centre_ex(gg_Buffer, font, itemv[i], box_w / 2 + box_l, 15 + box_t + (i * 10) + 2, 34, 60);
textout_centre_ex(gg_Buffer, font, itemv[i], box_w / 2 + box_l, 15 + box_t + (i * 10) + 2, 34, 60);
}
}
/* Blit the screen buffer */
vsync();
//blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
/* Now get the keyboard state */
if (getKeyStatus(KEY_UP))
if (key[KEY_UP])
{
usleep(100000);
if (selection <= 0)
@ -419,7 +404,7 @@ int DispMenu(int itemc, char *itemv[], char *title)
}
}
if (getKeyStatus(KEY_DOWN))
if (key[KEY_DOWN])
{
usleep(100000);
if (selection >= (itemc - 1))
@ -434,10 +419,9 @@ int DispMenu(int itemc, char *itemv[], char *title)
}
//release_bitmap(gg_Buffer);
while (getKeyStatus(KEY_ENTER))
release_bitmap(gg_Buffer);
while (key[KEY_ENTER])
{
vsync();
}
return selection;
}
@ -490,7 +474,7 @@ uint8_t gg_SelectPatch()
}
else
{
sprintf(tmp, "Patch %d: Put 0x%02X on address 0x%02X%02X (Code: %08X)",
sprintf(tmp, "Patch %d: Put 0x%02X on address 0x%02X%02X (Code: %08lX)",
i, gg_PatchedValue[i], gg_PatchedPage[i], gg_PatchedAddr[i],
gg_MakeCode((gg_PatchedPage[i] << 8) | gg_PatchedAddr[i], gg_PatchedValue[i]));
}
@ -714,9 +698,6 @@ void gg_Start()
int ret;
uint8_t value;
uint16_t addr;
console_printf(Console_Default, "Open GG plugin...\n");
switch (gg_state)
{
default:
@ -882,7 +863,7 @@ int gg_Init()
int i;
console_printf(Console_Default, "Initializing GG plugin...\n");
plugin_install_keypressHandler('G', gg_Start);
plugin_install_keypressHandler('g', gg_Start);
for (i = 0 ; i < GG_MAX_PATCH ; i++)
{
@ -896,4 +877,6 @@ int gg_Init()
int gg_Deinit()
{
return 0;
}
}
#endif

View File

@ -12,7 +12,7 @@
#include "plugins/gamegenie.h"
Plugin Plugins[] = {
{ "Game Genie", gg_Init, gg_Deinit },
// { "Game Genie", gg_Init, gg_Deinit },
/* EOL tag */
{ NULL, NULL, NULL }