Implemented MIN/MAX and updated command database. Updated project files.

This commit is contained in:
claudiol 2017-04-18 17:20:40 -04:00
parent 57387564e5
commit b73dae1c05
7 changed files with 203 additions and 16 deletions

View file

@ -207,12 +207,16 @@ SOURCES += firmware/ggl/ggl/ggl_bitblt.c \
firmware/hal_alarm.c \
firmware/ggl/ggl/ggl_fltreplace.c \
newrpl/lib-76-ui.c \
newrpl/lib-77-libdata.c \
newrpl/lib-zero-messages.c \
newrpl/lib-78-fonts.c \
newrpl/lib-80-bitmaps.c \
firmware/ui_forms.c \
firmware/ui_render.c \
newrpl/lib-88-plot.c
newrpl/lib-88-plot.c \
newrpl/fastmath.c \
newrpl/render.c
@ -236,7 +240,10 @@ HEADERS += firmware/include/ggl.h \
newrpl/romlibs.h \
firmware/include/fsystem.h \
firmware/sys/sddriver.h \
firmware/sys/fsystem/fsyspriv.h
firmware/sys/fsystem/fsyspriv.h \
newrpl/fastmath.h \
newrpl/render.h
INCLUDEPATH += firmware/include newrpl /usr/local/include /usr/include

View file

@ -208,13 +208,17 @@ SOURCES +=\
newrpl/lib-72-stack.c \
newrpl/lib-74-sdcard.c \
newrpl/lib-76-ui.c \
newrpl/lib-77-libdata.c \
newrpl/lib-78-fonts.c \
newrpl/lib-80-bitmaps.c \
newrpl/lib-88-plot.c \
firmware/ggl/ggl/ggl_fltreplace.c \
firmware/hal_alarm.c \
firmware/ui_render.c \
firmware/ui_forms.c
firmware/ui_forms.c \
newrpl/fastmath.c \
newrpl/render.c
HEADERS += \
firmware/include/ggl.h \
@ -234,12 +238,12 @@ HEADERS += \
firmware/sys/rtc.h \
firmware/sys/sddriver.h \
firmware/sys/fsystem/fsyspriv.h \
firmware/include/fsystem.h
firmware/include/fsystem.h \
newrpl/fastmath.h \
newrpl/render.h
RPL_OBJECTS = newrpl/rpl-objects/lib-0.nrpl \
newrpl/rpl-objects/lib-8.nrpl \
newrpl/rpl-objects/lib-54.nrpl \
RPL_OBJECTS = newrpl/rpl-objects/lib-54.nrpl \
newrpl/rpl-objects/lib-9.nrpl \
newrpl/rpl-objects/lib-10.nrpl \
newrpl/rpl-objects/lib-12.nrpl \
@ -249,8 +253,6 @@ RPL_OBJECTS = newrpl/rpl-objects/lib-0.nrpl \
newrpl/rpl-objects/lib-30.nrpl \
newrpl/rpl-objects/lib-32.nrpl \
newrpl/rpl-objects/lib-48.nrpl \
newrpl/rpl-objects/lib-52.nrpl \
newrpl/rpl-objects/lib-56.nrpl \
newrpl/rpl-objects/lib-62.nrpl \
newrpl/rpl-objects/lib-64.nrpl \
newrpl/rpl-objects/lib-65.nrpl \
@ -260,6 +262,11 @@ RPL_OBJECTS = newrpl/rpl-objects/lib-0.nrpl \
newrpl/rpl-objects/lib-72.nrpl \
newrpl/rpl-objects/lib-74.nrpl \
newrpl/rpl-objects/lib-76.nrpl \
newrpl/rpl-objects/lib-0.nrpl \
newrpl/rpl-objects/lib-8.nrpl \
newrpl/rpl-objects/lib-52.nrpl \
newrpl/rpl-objects/lib-56.nrpl \
newrpl/rpl-objects/lib-77.nrpl \
newrpl/rpl-objects/lib-80.nrpl \
newrpl/rpl-objects/lib-88.nrpl \
newrpl/rpl-objects/version.nrpl
@ -268,7 +275,6 @@ RPL_OBJECTS = newrpl/rpl-objects/lib-0.nrpl \
# This might need to be adapted to each cross-compiler installation
GCC_LIBDIR = /usr/lib/gcc/arm-none-eabi/4.9.3

View file

@ -74,7 +74,11 @@
CMD(PMUL,MKTOKENINFO(4,TITYPE_FUNCTION,2,2)), \
CMD(PADD,MKTOKENINFO(4,TITYPE_FUNCTION,2,2)), \
CMD(PSUB,MKTOKENINFO(4,TITYPE_FUNCTION,2,2)), \
ECMD(IPPOST,"",MKTOKENINFO(0,TITYPE_NOTALLOWED,1,2))
ECMD(IPPOST,"",MKTOKENINFO(0,TITYPE_NOTALLOWED,1,2)), \
CMD(MIN,MKTOKENINFO(3,TITYPE_FUNCTION,2,2)), \
CMD(MAX,MKTOKENINFO(3,TITYPE_FUNCTION,2,2))
// ADD MORE OPCODES HERE
@ -2642,9 +2646,94 @@ case IPPOST:
}
case MIN:
{
// COMPARE ANY 2 OBJECTS AND KEEP THE SMALLEST
if(rplDepthData()<2) {
rplError(ERR_BADARGCOUNT);
return;
}
if(ISLIST(*rplPeekData(2))||ISLIST(*rplPeekData(1))) {
// THIS IS A COMPOSITE, NEED TO RUN AN RPL LOOP
rplListBinaryDoCmd(rplPeekData(2),rplPeekData(1));
return;
}
if(ISIDENT(*rplPeekData(1)) || ISSYMBOLIC(*rplPeekData(2)) || ISIDENT(*rplPeekData(1)) || ISSYMBOLIC(*rplPeekData(1)))
{
rplSymbApplyOperator(CurOpcode,2);
return;
}
WORDPTR *saveStk=DSTop;
rplPushData(rplPeekData(2));
rplPushData(rplPeekData(2));
rplCallOvrOperator(CMD_OVR_LTE);
if(Exceptions) {
// CLEANUP THE STACK BEFORE RETURNING
DSTop=saveStk;
return;
}
if(rplIsFalse(rplPeekData(1))) {
// KEEP THE SECOND OBJECT
rplOverwriteData(3,rplPeekData(2));
}
rplDropData(2);
return;
}
case MAX:
{
// COMPARE ANY 2 OBJECTS AND KEEP THE SMALLEST
if(rplDepthData()<2) {
rplError(ERR_BADARGCOUNT);
return;
}
if(ISLIST(*rplPeekData(2))||ISLIST(*rplPeekData(1))) {
// THIS IS A COMPOSITE, NEED TO RUN AN RPL LOOP
rplListBinaryDoCmd(rplPeekData(2),rplPeekData(1));
return;
}
if(ISIDENT(*rplPeekData(1)) || ISSYMBOLIC(*rplPeekData(2)) || ISIDENT(*rplPeekData(1)) || ISSYMBOLIC(*rplPeekData(1)))
{
rplSymbApplyOperator(CurOpcode,2);
return;
}
WORDPTR *saveStk=DSTop;
rplPushData(rplPeekData(2));
rplPushData(rplPeekData(2));
rplCallOvrOperator(CMD_OVR_GTE);
if(Exceptions) {
// CLEANUP THE STACK BEFORE RETURNING
DSTop=saveStk;
return;
}
if(rplIsFalse(rplPeekData(1))) {
// KEEP THE SECOND OBJECT
rplOverwriteData(3,rplPeekData(2));
}
rplDropData(2);
return;
}
// ADD MORE OPCODES HERE

View file

@ -98,10 +98,7 @@ const char * const bitmap_modes[]={
#define RGB6TO8(comp) (((BINT)(comp)*1036)>>8)
#define TYPE_STARTPOINT 0
#define TYPE_LINE 1
#define TYPE_CTLPT 2
#define TYPE_CURVE 3
typedef struct {

View file

@ -34,5 +34,89 @@ void rndEvalCurve(FPINT t,CURVEPT * bezier,CURVEPT *result)
FPINT w2=(tsq*oneminust*3)>>24;
FPINT w3=(t*tsq)>>24;
result->x=mulFPINT(w0,bezier[0].x)+mulFPINT(w1,bezier[1].x)+mulFPINT(w2,bezier[2].x)+mulFPINT(w3,bezier[3].x);
result->y=mulFPINT(w0,bezier[0].y)+mulFPINT(w1,bezier[1].y)+mulFPINT(w2,bezier[2].y)+mulFPINT(w3,bezier[3].y);
}
// SAME AS THE OTHER FUNCTION BUT USES INTERPOLATION AND RETURNS THE FIRST DERIVATIVE
void rndEvalCurve2(FPINT t,CURVEPT * bezier,CURVEPT *result,CURVEPT *deriv)
{
CURVEPT temp[3+2+1];
// UNROLLED AND NOT RECURSIVE
temp[0].x=mulFPINT(t,bezier[0].x)+mulFPINT((1<<24)-t,bezier[1].x);
temp[0].y=mulFPINT(t,bezier[0].y)+mulFPINT((1<<24)-t,bezier[1].y);
temp[1].x=mulFPINT(t,bezier[1].x)+mulFPINT((1<<24)-t,bezier[2].x);
temp[1].y=mulFPINT(t,bezier[1].y)+mulFPINT((1<<24)-t,bezier[2].y);
temp[2].x=mulFPINT(t,bezier[2].x)+mulFPINT((1<<24)-t,bezier[3].x);
temp[2].y=mulFPINT(t,bezier[2].y)+mulFPINT((1<<24)-t,bezier[3].y);
temp[3].x=mulFPINT(t,temp[0].x)+mulFPINT((1<<24)-t,temp[1].x);
temp[3].y=mulFPINT(t,temp[0].y)+mulFPINT((1<<24)-t,temp[1].y);
temp[4].x=mulFPINT(t,temp[1].x)+mulFPINT((1<<24)-t,temp[2].x);
temp[4].y=mulFPINT(t,temp[1].y)+mulFPINT((1<<24)-t,temp[2].y);
result->x=mulFPINT(t,temp[3].x)+mulFPINT((1<<24)-t,temp[4].x);
result->y=mulFPINT(t,temp[3].y)+mulFPINT((1<<24)-t,temp[4].y);
deriv->x=temp[4].x-temp[3].x;
deriv->y=temp[4].y-temp[3].y;
}
// SCANS A POLYGON INTO A BUFFER. THE BUFFER HAS PAIRS OF FPINT NUMBERS
// THE FUNCTION WILL ALLOCATE A BUFFER AS LARGE AS NEEDED AND RETURN ITS POINTER
// THE BUFFER WILL BE INSIDE A TEMPORARY OBJECT IN TEMPOB (GC MIGHT BE TRIGGERED)
// THE BUFFER CONTAINS PAIRS OF SCANS STARTX+LENGTH. WHEN LENGTH<0 THEN Y COORDINATE
// MUST BE INCREMENTED BY ONE PIXEL AFTER PAINTING SCAN WITH (-LENGTH),
// OTHERWISE NEXT SCAN IS ON THE SAME LINE
// ARGUMENTS: poly = (CURVEPT *)POINTER TO THE CURVE DATA
// starty = FIRST SCAN LINE TO GENERATE
// endy = LAST SCAN LINE TO GENERATE
void rndScanPolygon(BINT npoints,CURVEPT *poly, FPINT starty, FPINT endy, FPINT **result)
{
BINT k;
// SCAN CONVERT ALL LINES
for(k=0;k<npoints;++k)
{
switch(poly[k].type)
{
case TYPE_STARTPOINT:
case TYPE_CTLPT:
case TYPE_CLOSEEND:
break; // NOTHING TO DO!
case TYPE_LINE:
// SCAN THE LINE AT [k-1] TO [k]
{
FPINT incx=divFPINT((poly[k].x-poly[k-1].x),poly[k].y-poly[k-1].y);
FPINT dy=0;
}
case TYPE_CURVE:
{
// SCAN A CUBIC BEZIER CURVE
}
break;
}
}
}

View file

@ -15,7 +15,11 @@ typedef struct {
BINT type;
} CURVEPT;
#define TYPE_STARTPOINT 0
#define TYPE_LINE 1
#define TYPE_CTLPT 2
#define TYPE_CURVE 3
#define TYPE_CLOSEEND 4