implement GCIRCLE X,Y,R,C
This commit is contained in:
@@ -321,10 +321,18 @@ class BuiltinFunction
|
||||
color.setDefaultValue(p.gcolor);
|
||||
p.gfill(p.useGRP, x, y, x2, y2, cast(int)color);
|
||||
}
|
||||
static void GCIRCLE(PetitComputer p, Value[])
|
||||
//X,Y,R[,COLOR]
|
||||
//X,Y,R,SR,ER[,COLOR]
|
||||
static void GCIRCLE(PetitComputer p, int x, int y, int r, DefaultValue!(int, false) color)
|
||||
{
|
||||
//color.setDefaultValue(p.gcolor);
|
||||
//p.gfill(p.useGRP, x, y, x2, y2, cast(int)color);
|
||||
color.setDefaultValue(p.gcolor);
|
||||
p.gcircle(p.useGRP, x, y, r, 0, 360, 0, cast(int)color);
|
||||
}
|
||||
static void GCIRCLE(PetitComputer p, int x, int y, int r, int sr, int er, DefaultValue!(int, false) flag, DefaultValue!(int, false) color)
|
||||
{
|
||||
color.setDefaultValue(p.gcolor);
|
||||
flag.setDefaultValue(0);
|
||||
p.gcircle(p.useGRP, x, y, r, sr, er, cast(int)flag, cast(int)color);
|
||||
}
|
||||
static void GCOLOR(PetitComputer p, int color)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ import std.file;
|
||||
import std.stdio;
|
||||
import std.conv;
|
||||
import std.string;
|
||||
import std.c.stdio;
|
||||
import core.stdc.stdio;
|
||||
import core.sync.mutex;
|
||||
import core.sync.condition;
|
||||
import otya.smilebasic.sprite;
|
||||
@@ -674,6 +674,18 @@ class PetitComputer
|
||||
glLoadIdentity();
|
||||
glOrtho(0, w, h, 0, 1024, -2048);
|
||||
}
|
||||
void drawCircle(int x, int y, int r, int startr, int endr, int flag)
|
||||
{
|
||||
import std.math : sin, cos, PI;
|
||||
int count = r;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (int i = 0; i <= r; i++)
|
||||
{
|
||||
//float a = i * (360f / r);
|
||||
glVertex2f(sin(cast(float)i / count * 2f * PI) * r + x, cos(cast(float)i / count * 2f * PI) * r + y);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
void renderGraphic()
|
||||
{
|
||||
if(!drawMessageLength) return;
|
||||
@@ -773,6 +785,12 @@ class PetitComputer
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DrawType.CIRCLE:
|
||||
{
|
||||
glColor4ubv(cast(ubyte*)&dm.color);
|
||||
drawCircle(dm.x, dm.y, dm.circle.r, dm.circle.startr, dm.circle.endr, dm.circle.flag);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
dt = dm.type;
|
||||
@@ -1622,6 +1640,11 @@ class PetitComputer
|
||||
TRI,
|
||||
PAINT,
|
||||
}
|
||||
struct Circle
|
||||
{
|
||||
short r, startr, endr;
|
||||
short flag;
|
||||
}
|
||||
struct DrawMessage
|
||||
{
|
||||
DrawType type;
|
||||
@@ -1631,13 +1654,14 @@ class PetitComputer
|
||||
uint color;
|
||||
short x2;
|
||||
short y2;
|
||||
Circle circle;
|
||||
//
|
||||
}
|
||||
static const int dmqqueuelen = 8192;
|
||||
DrawMessage[] drawMessageQueue = new DrawMessage[dmqqueuelen];
|
||||
int drawMessageLength;
|
||||
bool drawflag;
|
||||
void sendDrawMessage(DrawType type, byte page, short x, short y, uint color)
|
||||
void sendDrawMessage(DrawMessage dm)
|
||||
{
|
||||
//grpmutex.lock();
|
||||
//scope(exit)
|
||||
@@ -1650,30 +1674,31 @@ class PetitComputer
|
||||
}
|
||||
}
|
||||
while(drawflag){}
|
||||
drawMessageQueue[drawMessageLength].type = type;
|
||||
drawMessageQueue[drawMessageLength].page = page;
|
||||
drawMessageQueue[drawMessageLength].x = x;
|
||||
drawMessageQueue[drawMessageLength].y = y;
|
||||
drawMessageQueue[drawMessageLength].color = toGLColor(this.GRP[0].textureFormat, color & 0xFFF8F8F8);
|
||||
dm.color = toGLColor(this.GRP[0].textureFormat, dm.color & 0xFFF8F8F8);
|
||||
drawMessageQueue[drawMessageLength] = dm;
|
||||
drawMessageLength++;
|
||||
}
|
||||
void sendDrawMessage(DrawType type, byte page, short x, short y, uint color)
|
||||
{
|
||||
DrawMessage dm;
|
||||
dm.type = type;
|
||||
dm.page = page;
|
||||
dm.x = x;
|
||||
dm.y = y;
|
||||
dm.color = color;
|
||||
sendDrawMessage(dm);
|
||||
}
|
||||
void sendDrawMessage(DrawType type, byte page, short x, short y, short x2, short y2, uint color)
|
||||
{
|
||||
if(drawMessageLength >= dmqqueuelen)
|
||||
{
|
||||
while(drawMessageLength)
|
||||
{
|
||||
SDL_Delay(1);
|
||||
}
|
||||
}
|
||||
drawMessageQueue[drawMessageLength].type = type;
|
||||
drawMessageQueue[drawMessageLength].page = page;
|
||||
drawMessageQueue[drawMessageLength].x = x;
|
||||
drawMessageQueue[drawMessageLength].y = y;
|
||||
drawMessageQueue[drawMessageLength].x2 = x2;
|
||||
drawMessageQueue[drawMessageLength].y2 = y2;
|
||||
drawMessageQueue[drawMessageLength].color = toGLColor(this.GRP[0].textureFormat, color & 0xFFF8F8F8);
|
||||
drawMessageLength++;
|
||||
DrawMessage dm;
|
||||
dm.type = type;
|
||||
dm.page = page;
|
||||
dm.x = x;
|
||||
dm.y = y;
|
||||
dm.x2 = x2;
|
||||
dm.y2 = y2;
|
||||
dm.color = color;
|
||||
sendDrawMessage(dm);
|
||||
}
|
||||
//TODO:範囲チェック
|
||||
void gpset(int page, int x, int y, uint color)
|
||||
@@ -1696,6 +1721,20 @@ class PetitComputer
|
||||
{
|
||||
sendDrawMessage(DrawType.PAINT, cast(byte)page, cast(short)x, cast(short)y, color);
|
||||
}
|
||||
void gcircle(int page, int x, int y, int r, int startr, int endr, int flag, uint color)
|
||||
{
|
||||
DrawMessage dm;
|
||||
dm.page = cast(byte)page;
|
||||
dm.x = cast(short)x;
|
||||
dm.y = cast(short)y;
|
||||
dm.circle.r = cast(short)r;
|
||||
dm.circle.startr = cast(short)startr;
|
||||
dm.circle.endr = cast(short)endr;
|
||||
dm.circle.flag = cast(short)flag;
|
||||
dm.color = color;
|
||||
dm.type = DrawType.CIRCLE;
|
||||
sendDrawMessage(dm);
|
||||
}
|
||||
int gprio;
|
||||
void renderGraphicPage(int display, float w, float h)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user