mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Untested fixups
This commit is contained in:
parent
6fbc7a6301
commit
bccf27f29f
@ -220,6 +220,7 @@ typedef cc_uint8 cc_bool;
|
|||||||
#define CC_BUILD_MACCLASSIC
|
#define CC_BUILD_MACCLASSIC
|
||||||
#define CC_BUILD_HTTPCLIENT
|
#define CC_BUILD_HTTPCLIENT
|
||||||
#define CC_BUILD_OPENAL
|
#define CC_BUILD_OPENAL
|
||||||
|
#define CC_BUILD_COOPTHREADED
|
||||||
#elif defined __sun__
|
#elif defined __sun__
|
||||||
#define CC_BUILD_SOLARIS
|
#define CC_BUILD_SOLARIS
|
||||||
#define CC_BUILD_POSIX
|
#define CC_BUILD_POSIX
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#undef true
|
#undef true
|
||||||
#undef false
|
#undef false
|
||||||
#include <MacMemory.h>
|
#include <MacMemory.h>
|
||||||
|
#include <Timer.h>
|
||||||
|
|
||||||
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
|
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
|
||||||
const cc_result ReturnCode_FileNotFound = ENOENT;
|
const cc_result ReturnCode_FileNotFound = ENOENT;
|
||||||
@ -107,12 +108,16 @@ void DateTime_CurrentLocal(struct DateTime* t) {
|
|||||||
#define NS_PER_SEC 1000000000ULL
|
#define NS_PER_SEC 1000000000ULL
|
||||||
|
|
||||||
cc_uint64 Stopwatch_Measure(void) {
|
cc_uint64 Stopwatch_Measure(void) {
|
||||||
return clock();
|
//return TickCount();
|
||||||
|
UnsignedWide count;
|
||||||
|
Microseconds(&count);
|
||||||
|
return (cc_uint64)count.lo | ((cc_uint64)count.hi << 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
||||||
if (end < beg) return 0;
|
if (end < beg) return 0;
|
||||||
return (end - beg) / 1000;
|
return end - beg;
|
||||||
|
//return (end - beg) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stopwatch_Init(void) {
|
void Stopwatch_Init(void) {
|
||||||
|
@ -14,67 +14,74 @@
|
|||||||
#include <Dialogs.h>
|
#include <Dialogs.h>
|
||||||
#include <Fonts.h>
|
#include <Fonts.h>
|
||||||
#include <Events.h>
|
#include <Events.h>
|
||||||
static WindowPtr win;
|
#include <Scrap.h>
|
||||||
Rect r;
|
|
||||||
BitMap bitmapScreen;
|
|
||||||
|
|
||||||
#define SCREEN_WIDTH 320
|
static WindowPtr win;
|
||||||
#define SCREEN_HEIGHT 224
|
static cc_bool launcherMode;
|
||||||
static cc_bool launcherMode = true;
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------Public implementation--------------------------------------------------*
|
*--------------------------------------------------Public implementation--------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Window_PreInit(void) { }
|
void Window_PreInit(void) { }
|
||||||
void Window_Init(void) {
|
void Window_Init(void) {
|
||||||
DisplayInfo.Width = SCREEN_WIDTH;
|
|
||||||
DisplayInfo.Height = SCREEN_HEIGHT;
|
|
||||||
DisplayInfo.ScaleX = 0.5f;
|
|
||||||
DisplayInfo.ScaleY = 0.5f;
|
|
||||||
|
|
||||||
Window_Main.Width = DisplayInfo.Width;
|
|
||||||
Window_Main.Height = DisplayInfo.Height;
|
|
||||||
Window_Main.Focused = true;
|
|
||||||
Window_Main.Exists = true;
|
|
||||||
|
|
||||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
|
||||||
DisplayInfo.ContentOffsetX = 10;
|
|
||||||
DisplayInfo.ContentOffsetY = 10;
|
|
||||||
|
|
||||||
InitGraf(&qd.thePort);
|
InitGraf(&qd.thePort);
|
||||||
InitFonts();
|
InitFonts();
|
||||||
InitWindows();
|
InitWindows();
|
||||||
InitMenus();
|
InitMenus();
|
||||||
|
InitDialogs(NULL);
|
||||||
|
InitCursor();
|
||||||
|
|
||||||
|
FlushEvents(everyEvent, 0);
|
||||||
|
|
||||||
|
Rect r = qd.screenBits.bounds;
|
||||||
|
DisplayInfo.x = r.left;
|
||||||
|
DisplayInfo.y = r.top;
|
||||||
|
DisplayInfo.Width = r.right - r.left; // TODO +1 or not?
|
||||||
|
DisplayInfo.Height = r.bottom - r.top;
|
||||||
|
|
||||||
|
DisplayInfo.ScaleX = 1.0f;
|
||||||
|
DisplayInfo.ScaleY = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Free(void) { }
|
void Window_Free(void) { }
|
||||||
|
|
||||||
static void DoCreateWindow(int width, int height) {
|
static void DoCreateWindow(int width, int height) {
|
||||||
r = qd.screenBits.bounds;
|
|
||||||
Rect windR;
|
Rect windR;
|
||||||
/* TODO: Make less-crap method of getting center. */
|
/* TODO: Make less-crap method of getting center. */
|
||||||
int centerX = r.right/2; int centerY = r.bottom/2;
|
int middleX = Display_CentreX(width);
|
||||||
int ww = (SCREEN_WIDTH/2); int hh = (SCREEN_HEIGHT/2);
|
int middleY = Display_CentreY(height);
|
||||||
SetRect(&bitmapScreen.bounds, 0, 0, width, height);
|
|
||||||
|
|
||||||
// TODO
|
SetRect(&windR, middleX - width / 2, middleY - height / 2,
|
||||||
SetRect(&windR, centerX-ww, centerY-hh, centerX+ww, centerY+hh);
|
middleX + width / 2, middleY + height / 2);
|
||||||
win = NewWindow(NULL, &windR, "\pClassiCube", true, 0, (WindowPtr)-1, false, 0);
|
win = NewWindow(NULL, &windR, "\pClassiCube", true, 0, (WindowPtr)-1, false, 0);
|
||||||
SetPort(win);
|
SetPort(win);
|
||||||
|
|
||||||
|
Window_Main.Width = width;
|
||||||
|
Window_Main.Height = height;
|
||||||
|
Window_Main.Focused = true;
|
||||||
|
Window_Main.Exists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create2D(int width, int height) { launcherMode=true; DoCreateWindow(width, height); }
|
void Window_Create2D(int width, int height) { launcherMode = true; DoCreateWindow(width, height); }
|
||||||
void Window_Create3D(int width, int height) { launcherMode=false; DoCreateWindow(width, height); }
|
void Window_Create3D(int width, int height) { launcherMode = false; DoCreateWindow(width, height); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard_GetText(cc_string* value) {
|
void Clipboard_GetText(cc_string* value) {
|
||||||
|
Handle tmp = NewHandle(0);
|
||||||
|
HLock(tmp);
|
||||||
|
int dataSize = GetScrap(tmp, 'TEXT', 0);
|
||||||
|
HUnlock(tmp);
|
||||||
|
|
||||||
|
String_AppendAll(value, (char*)tmp, dataSize);
|
||||||
|
DisposeHandle(tmp);
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard_SetText(const cc_string* value) {
|
void Clipboard_SetText(const cc_string* value) {
|
||||||
|
PutScrap(value->length, 'TEXT', value->buffer);
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +115,10 @@ void Window_RequestClose(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window_ProcessEvents(float delta) {
|
void Window_ProcessEvents(float delta) {
|
||||||
// TODO
|
EventRecord event;
|
||||||
|
|
||||||
|
while (GetNextEvent(everyEvent, &event)) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short isPressed(unsigned short k) {
|
short isPressed(unsigned short k) {
|
||||||
@ -118,9 +128,7 @@ short isPressed(unsigned short k) {
|
|||||||
return ((km[k>>3] >> (k&7) ) &1);
|
return ((km[k>>3] >> (k&7) ) &1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int theKeys;
|
|
||||||
void Window_ProcessGamepads(float delta) {
|
void Window_ProcessGamepads(float delta) {
|
||||||
GetKeys(theKeys);
|
|
||||||
Gamepad_SetButton(0, CCPAD_UP, isPressed(0x0D));
|
Gamepad_SetButton(0, CCPAD_UP, isPressed(0x0D));
|
||||||
Gamepad_SetButton(0, CCPAD_DOWN, isPressed(0x01));
|
Gamepad_SetButton(0, CCPAD_DOWN, isPressed(0x01));
|
||||||
Gamepad_SetButton(0, CCPAD_START, isPressed(0x24));
|
Gamepad_SetButton(0, CCPAD_START, isPressed(0x24));
|
||||||
@ -128,14 +136,18 @@ void Window_ProcessGamepads(float delta) {
|
|||||||
|
|
||||||
static void Cursor_GetRawPos(int* x, int* y) {
|
static void Cursor_GetRawPos(int* x, int* y) {
|
||||||
// TODO
|
// TODO
|
||||||
*x=0;*y=0;
|
*x=0;*y=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetPosition(int x, int y) {
|
void Cursor_SetPosition(int x, int y) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
static void Cursor_DoSetVisible(cc_bool visible) {
|
static void Cursor_DoSetVisible(cc_bool visible) {
|
||||||
// TODO
|
if (visible) {
|
||||||
|
ShowCursor();
|
||||||
|
} else {
|
||||||
|
HideCursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowDialogCore(const char* title, const char* msg) {
|
static void ShowDialogCore(const char* title, const char* msg) {
|
||||||
@ -156,7 +168,6 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) {
|
|||||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
|
bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GetWindowPort(w) w
|
|
||||||
void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) {
|
void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) {
|
||||||
// Grab Window port.
|
// Grab Window port.
|
||||||
GrafPtr thePort = GetWindowPort(win);
|
GrafPtr thePort = GetWindowPort(win);
|
||||||
@ -170,9 +181,9 @@ void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) {
|
|||||||
|
|
||||||
// TODO optimise
|
// TODO optimise
|
||||||
BitmapCol col = row[x];
|
BitmapCol col = row[x];
|
||||||
cc_uint8 R = BitmapCol_R(col);
|
cc_uint8 R = BitmapCol_R(col);
|
||||||
cc_uint8 G = BitmapCol_G(col);
|
cc_uint8 G = BitmapCol_G(col);
|
||||||
cc_uint8 B = BitmapCol_B(col);
|
cc_uint8 B = BitmapCol_B(col);
|
||||||
|
|
||||||
// Set the pixel color in the window
|
// Set the pixel color in the window
|
||||||
RGBColor pixelColor;
|
RGBColor pixelColor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user