mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-18 02:30:48 +00:00
reduce namespace pollution from console library
This commit is contained in:
parent
c9f832b2c9
commit
4e766452b4
@ -24,6 +24,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Retro;
|
||||
|
||||
Console *Console::currentInstance = NULL;
|
||||
|
||||
Console::Console(GrafPtr port, Rect r)
|
||||
|
@ -21,9 +21,12 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class Console
|
||||
namespace Retro
|
||||
{
|
||||
public:
|
||||
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
Console(GrafPtr port, Rect r);
|
||||
~Console();
|
||||
void Draw();
|
||||
@ -33,7 +36,7 @@ public:
|
||||
std::string ReadLine();
|
||||
|
||||
static Console *currentInstance;
|
||||
private:
|
||||
private:
|
||||
GrafPtr consolePort;
|
||||
Rect bounds;
|
||||
|
||||
@ -55,5 +58,7 @@ private:
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
@ -54,7 +59,7 @@ void InitConsole()
|
||||
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();
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
__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;
|
||||
}
|
||||
|
@ -23,6 +23,10 @@
|
||||
#include <Files.h>
|
||||
#include <Devices.h>
|
||||
|
||||
#include <Quickdraw.h>
|
||||
QDGlobals qd;
|
||||
|
||||
|
||||
pascal Size GetPtrSize(Ptr ptr)
|
||||
{
|
||||
long tmp;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user