4 Commits

Author SHA1 Message Date
Godzil
ba5310c986 Update nanogui 2020-02-11 02:15:06 +01:00
Godzil
366e1dc067 Starting to work on making a proper GUI 2020-02-07 17:45:23 +00:00
Godzil
4280979f87 Fix warnings/errors spotted by travis 2020-01-17 18:13:06 +00:00
Godzil
2ec7a9c21e Working on plugin to make them work again! 2020-01-14 18:59:22 +00:00
22 changed files with 302 additions and 364 deletions

3
.gitmodules vendored
View File

@@ -7,3 +7,6 @@
[submodule "external/portaudio"] [submodule "external/portaudio"]
path = external/portaudio path = external/portaudio
url = https://git.assembla.com/portaudio.git url = https://git.assembla.com/portaudio.git
[submodule "external/nanogui"]
path = external/nanogui
url = https://github.com/Godzil/nanogui.git

View File

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

1
external/nanogui vendored Submodule

Submodule external/nanogui added at 16bc6b1d3a

View File

@@ -15,17 +15,18 @@ 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_EFENCE OFF CACHE BOOL "Use electricfence memory debugger?")
set(USE_PROFILING OFF CACHE BOOL "Use profiling tools? (Will slow down a lot.)") 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(COVERALLS "Generate coveralls data" OFF)
########################## ##########################
# Link & Compile flags # Link & Compile flags
########################## ##########################
#set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -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_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_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake)
add_executable(petines main.c paddle.c NESCarts.c) add_executable(petines main.c paddle.c NESCarts.c)
@@ -67,20 +68,6 @@ endif ()
include_directories(include) 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(apu)
add_subdirectory(corecpu) add_subdirectory(corecpu)
add_subdirectory(mappersmanager) add_subdirectory(mappersmanager)
@@ -89,9 +76,14 @@ add_subdirectory(pluginsmanager)
add_subdirectory(ppu) add_subdirectory(ppu)
if ( (NOT ${OS_TARGET} STREQUAL "TI68K") AND (NOT ${OS_TARGET} STREQUAL "32BLIT") ) if (TARGET_TI68k)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/external/coveralls-cmake/cmake) add_subdirectory(os/ti68k)
endif () elseif (WIN32)
add_subdirectory(os/win32)
else (TARGET_TI68k)
add_subdirectory(os/unix)
endif (TARGET_TI68k)
#find_library(PTHREADLIB pthread) #find_library(PTHREADLIB pthread)
if (COVERALLS) if (COVERALLS)

View File

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

View File

@@ -11,13 +11,18 @@
#define OS_DEPENDENT_H #define OS_DEPENDENT_H
#include <stdint.h> #include <stdint.h>
#include "text.h"
/* File related functions */ /* File related functions */
/* Graphics related functions */ /* Graphics related functions */
int graphics_init(); int graphics_init();
int graphics_drawpixel(long x, long y, long color); int graphics_drawpixel(long x, long y, long color);
int graphics_blit(long x, long y, long w, long h); int graphics_blit(long x, long y, long w, long h);
int graphics_drawline(long x, long y, long x1, long y1, long color); 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);
void vsync(void); void vsync(void);
typedef struct Palette_t typedef struct Palette_t
@@ -47,4 +52,15 @@ int console_init(ConsoleLevel DefaultLevel);
int console_printf(const ConsoleLevel level, const char *format, ...); int console_printf(const ConsoleLevel level, const char *format, ...);
int console_printf_d(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 */ #endif /* OS_DEPENDENT_H */

View File

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

58
src/include/text.h Normal file
View File

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

View File

@@ -1,17 +0,0 @@
#
# 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)

View File

@@ -1,86 +0,0 @@
/*
* 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)
{
}

View File

@@ -1,59 +0,0 @@
/*
* 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;
}

View File

@@ -1,39 +0,0 @@
/*
* 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;
}

View File

View File

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

View File

@@ -120,11 +120,28 @@ int graphics_drawpixel(long x, long y, long color)
return 0; return 0;
} }
int graphics_drawline(long x, long y, long x1, long y1, long color) int graphics_drawline(uint32_t x, uint32_t y, uint32_t x1, uint32_t y1, uint32_t colour)
{ {
return 0; 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) int graphics_blit(long x, long y, long w, long h)
{ {
return 0; return 0;

View File

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

View File

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

View File

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