diff --git a/Console/Console.cc b/Console/Console.cc index 3ccba53b14..cdb002f257 100644 --- a/Console/Console.cc +++ b/Console/Console.cc @@ -24,6 +24,8 @@ #include +using namespace Retro; + Console *Console::currentInstance = NULL; Console::Console(GrafPtr port, Rect r) diff --git a/Console/Console.h b/Console/Console.h index 3468bf937a..a976820f1e 100644 --- a/Console/Console.h +++ b/Console/Console.h @@ -21,39 +21,44 @@ #include #include -class Console +namespace Retro { -public: - Console(GrafPtr port, Rect r); - ~Console(); - void Draw(); - void putch(char c); - void write(const char *s, int n); - std::string ReadLine(); + class Console + { + public: + Console(GrafPtr port, Rect r); + ~Console(); + void Draw(); + void putch(char c); - static Console *currentInstance; -private: - GrafPtr consolePort; - Rect bounds; + void write(const char *s, int n); + std::string ReadLine(); - std::vector chars, onscreen; + static Console *currentInstance; + private: + GrafPtr consolePort; + Rect bounds; - short cellSizeX; - short cellSizeY; + std::vector chars, onscreen; - short rows, cols; + short cellSizeX; + short cellSizeY; - short cursorX, cursorY; + short rows, cols; - Rect dirtyRect; + short cursorX, cursorY; - void PutCharNoUpdate(char c); - void Update(); + Rect dirtyRect; - Rect CellRect(short x, short y); - void DrawCell(short x, short y, bool erase = true); - void DrawCells(short x1, short x2, short y, bool erase = true); - void ScrollUp(short n = 1); -}; + void PutCharNoUpdate(char c); + void Update(); + Rect CellRect(short x, short y); + void DrawCell(short x, short y, bool erase = true); + void DrawCells(short x1, short x2, short y, bool erase = true); + void ScrollUp(short n = 1); + }; + + +} diff --git a/Console/InitConsole.cc b/Console/InitConsole.cc index 1fb6c6f68e..d3161ec5bd 100644 --- a/Console/InitConsole.cc +++ b/Console/InitConsole.cc @@ -31,9 +31,14 @@ #include "MacUtils.h" #include "Console.h" -QDGlobals qd; +namespace Retro +{ + void InitConsole(); +} -void InitConsole() +using namespace Retro; + +void Retro::InitConsole() { if(Console::currentInstance) return; @@ -43,18 +48,18 @@ void InitConsole() InitFonts(); InitWindows(); InitMenus(); - + Rect r; SetRect(&r, qd.screenBits.bounds.left + 5, qd.screenBits.bounds.top + 45, qd.screenBits.bounds.right - 5, qd.screenBits.bounds.bottom -5); win = NewWindow(NULL, &r, "\pRetro68 Console", true, 0, (WindowPtr)-1, false, 0); - + SetPort(win); EraseRect(&win->portRect); Console *console = new Console(win, win->portRect); } -extern "C" ssize_t consolewrite(int fd, const void *buf, size_t count) +extern "C" ssize_t _consolewrite(int fd, const void *buf, size_t count) { if(!Console::currentInstance) InitConsole(); @@ -63,7 +68,7 @@ extern "C" ssize_t consolewrite(int fd, const void *buf, size_t count) return count; } -extern "C" ssize_t consoleread(int fd, void *buf, size_t count) +extern "C" ssize_t _consoleread(int fd, void *buf, size_t count) { if(!Console::currentInstance) InitConsole(); diff --git a/libretro/consolehooks.c b/libretro/consolehooks.c index 44c34b51d5..47c6692ba5 100644 --- a/libretro/consolehooks.c +++ b/libretro/consolehooks.c @@ -1,11 +1,11 @@ #include -__attribute__((weak)) ssize_t consolewrite(int fd, const void *buf, size_t count) +__attribute__((weak)) ssize_t _consolewrite(int fd, const void *buf, size_t count) { return -1; } -__attribute__((weak)) ssize_t consoleread(int fd, void *buf, size_t count) +__attribute__((weak)) ssize_t _consoleread(int fd, void *buf, size_t count) { return -1; } diff --git a/libretro/glue.c b/libretro/glue.c index 0541538d6b..f46691f27f 100644 --- a/libretro/glue.c +++ b/libretro/glue.c @@ -23,6 +23,10 @@ #include #include +#include +QDGlobals qd; + + pascal Size GetPtrSize(Ptr ptr) { long tmp; diff --git a/libretro/syscalls.c b/libretro/syscalls.c index feacdb6959..8488365545 100644 --- a/libretro/syscalls.c +++ b/libretro/syscalls.c @@ -32,40 +32,28 @@ void *sbrk(long increment) void _exit(int status) { - if(status != 0) - Debugger(); + //if(status != 0) + // Debugger(); ExitToShell(); for(;;) ; } -ssize_t (*__write_hook)(int fd, const void*buf, size_t count) = NULL; -ssize_t (*__read_hook)(int fd, void*buf, size_t count) = NULL; - -ssize_t consolewrite(int fd, const void *buf, size_t count); -ssize_t consoleread(int fd, void *buf, size_t count); +ssize_t _consolewrite(int fd, const void *buf, size_t count); +ssize_t _consoleread(int fd, void *buf, size_t count); ssize_t write(int fd, const void *buf, size_t count) { - if(__write_hook) - return (*__write_hook)(fd,buf,count); - else - return consolewrite(fd,buf,count); - return -1; + return _consolewrite(fd,buf,count); } ssize_t read(int fd, void *buf, size_t count) { - if(__read_hook) - return (*__read_hook)(fd,buf,count); - else - return consoleread(fd,buf,count); - return -1; + return _consoleread(fd,buf,count); } int open(const char* name, int flags, mode_t mode) { - __asm__ __volatile__ ("dc.w 0xa9ff"); return -1; }