mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-29 12:50:35 +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,39 +21,44 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
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<char> chars, onscreen;
|
||||
static Console *currentInstance;
|
||||
private:
|
||||
GrafPtr consolePort;
|
||||
Rect bounds;
|
||||
|
||||
short cellSizeX;
|
||||
short cellSizeY;
|
||||
std::vector<char> 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);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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…
Reference in New Issue
Block a user