TempleOSCD_140715.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:09 +02:00
1 parent 7ef616a20e
commit 64f679eeb9
1095 files changed
+24814 -221011

No files matched your search

+4 -4
View File
@@ -9,12 +9,12 @@ U0 Main()
while (!ScanChar) {
DCDepthBufRst(dc);
GrSetSymmetry(dc,Fs->pix_width/2,Fs->pix_height/2,
ipx-Fs->pix_left-Fs->scroll_x,
ipy-Fs->pix_top-Fs->scroll_y);
ip.pos.x-Fs->pix_left-Fs->scroll_x,
ip.pos.y-Fs->pix_top-Fs->scroll_y);
dc->color=LTBLUE;
GrLine(dc,Fs->pix_width/2,Fs->pix_height/2,
ipx-Fs->pix_left-Fs->scroll_x,
ipy-Fs->pix_top-Fs->scroll_y);
ip.pos.x-Fs->pix_left-Fs->scroll_x,
ip.pos.y-Fs->pix_top-Fs->scroll_y);
GrIdentEqu(dc->r);
GrRotXEqu(dc->r,ę);
+5 -5
View File
@@ -1,21 +1,21 @@
U0 BSplineDemo()
{
CDC *dc=DCAlias;
I64 p1,p2,i=0,msg_code;
I64 a1,a2,i=0,msg_code;
CD3I32 c[64];
SettingsPush;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
DocClear;
"Select ctrl points with left mouse. Right when finished.\n";
DCFill;
do {
msg_code=GetMsg(&p1,&p2,1<<MSG_IP_L_UP+1<<MSG_IP_R_UP);
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP+1<<MSG_IP_R_UP);
if (msg_code==MSG_IP_L_UP) {
c[i].x=p1; c[i].y=p2; c[i].z=0;
c[i].x=a1; c[i].y=a2; c[i].z=0;
dc->color=GREEN;
GrCircle(dc,p1,p2,10);
GrCircle(dc,a1,a2,10);
i++;
}
} while (msg_code!=MSG_IP_R_UP);
+1 -1
View File
@@ -14,7 +14,7 @@ U0 Balloon()
OutU8(VGA_SC_INDEX,VGA_MAP_MASK);
OutU8(VGA_SC_DATA,0xF);
MemSetU64(0xA0000,0,640*480/64);
MemSetI64(0xA0000,0,640*480/64);
OutU8(VGA_SC_INDEX,VGA_MAP_MASK);
OutU8(VGA_SC_DATA,RED+GREEN+8);
+1 -1
View File
@@ -31,7 +31,7 @@ for (i=0;i<256;i+=4) {
U8 *tempg=DC2Sprite(img1);
Sprite(tempg);
Free(tempg);
NewLine(9);
"%h9c",'\n';
DCDel(img1);
DCDel(img2);
+7 -16
View File
@@ -1,4 +1,4 @@
//This uses $LK,"fixed-point-arithmetic",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
//Uses $LK,"fixed-point-arithmetic",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
I64 x[16],y[16],dx[16],dy[16];
@@ -18,11 +18,11 @@ U0 Init()
U0 Bounce()
{
CDC *dc=DCAlias;
I64 i,msg_code,p1,update;
I64 i,ch,update;
Init;
try { //Catch <CTRL-ALT-C>
while (TRUE) {
update=win_updates;
try {//Catch <CTRL-ALT-c>
do {
update=winmgr.updates;
do for (i=0;i<16;i++) {
dc->color=i;
GrPlot(dc,x[i].i32[1],y[i].i32[1]);
@@ -37,17 +37,8 @@ U0 Bounce()
dy[i]=-dy[i];
}
}
while (update==win_updates);
while (msg_code=ScanMsg(&p1,NULL,1<<MSG_KEY_DOWN|1<<MSG_RESIZE|1<<MSG_MOVE))
if (msg_code==MSG_KEY_DOWN) {
if (p1==CH_SHIFT_ESC || p1==CH_ESC)
goto bc_done;
else
Init;
} else
DCFill(dc);
}
bc_done:
while (update==winmgr.updates);
} while (!(ch=ScanChar) || (ch!=CH_SHIFT_ESC && ch!=CH_ESC));
} catch
PutExcept;
DCFill(dc);
+2 -2
View File
@@ -2,7 +2,7 @@ CDC *dc;
U0 DrawIt(CTask *,CDC *)
{//This technique is weird, but clever. In Box() we
//created an alias of the system $LK,"gr_dc2",A="MN:gr_dc2"$.
//created an alias of the system $LK,"gr.dc2",A="MN:CGrGlbls"$.
dc->pen_width=2;
dc->color=RED;
GrLine3(dc,-100,-100,-100, -100, 100,-100);
@@ -22,7 +22,7 @@ U0 DrawIt(CTask *,CDC *)
U0 Box()
{
F64 é=0,è=0,ê=0,s=1,s1=1.05;
dc=DCAlias(gr_dc2,Fs);
dc=DCAlias(gr.dc2,Fs);
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
DocClear;
Binary file not shown.
-1
View File
@@ -9,7 +9,6 @@ U0 ViewScreenCapture(U8 *filename)
DCDel(dc);
}
U0 Main()
{
"Capture screen...\n";
+4 -4
View File
@@ -14,7 +14,7 @@ U0 Cartesian()
"Enter algebraic equation to graph.\n"
"Example: y=2*x\n"
"y=";
if (st=MGetS) {
if (st=GetStr) {
if (*st) {
h=Fs->pix_width/2;
v=Fs->pix_height/2;
@@ -43,6 +43,6 @@ U0 Cartesian()
Cartesian;
/*$WW,1$
For better performance, compile the expression entered by the user one time with $LK,"LexExpression2Bin",A="MN:LexExpression2Bin"$() and use $LK,"Call",A="MN:Call"$(). See $LK,"::/Demo/CompileDemo.CPP"$.
*/
//For better performance, compile the expression entered by the
//user one time with $LK,"LexExpression2Bin",A="MN:LexExpression2Bin"$() and use $LK,"Call",A="MN:Call"$().
//See $LK,"::/Demo/CompileDemo.CPP"$.
+6 -9
View File
@@ -1,9 +1,7 @@
U8 *old_font=gr_font;
U8 *old_font=text.font;
// See $LK,"::/Kernel/Font8x8.CPP"$.
// See $LK,"::/Demo/ScreenCodes.CPP"$.
// See $LK,"::/Demo/ExtendedChars.CPP"$.
// See $LK,"::/Demo/Graphics/FontEd.CPP"$.
// See $LK,"::/Kernel/Font8x8.CPP"$, $LK,"::/Demo/ScreenCodes.CPP"$,
//$LK,"::/Demo/ExtendedChars.CPP"$, and $LK,"::/Demo/Graphics/FontEd.CPP"$.
U8 waves[8*4]={
0x00,0x11,0xAA,0x44,0x00,0x11,0xAA,0x44,
@@ -13,7 +11,7 @@ U8 waves[8*4]={
U0 AnimateEndCB()
{
gr_font=old_font;
text.font=old_font;
Exit;
}
@@ -22,14 +20,13 @@ U0 AnimateTask(I64)
I64 i;
U8 *font=MAlloc(256*8);
Fs->task_end_cb=&AnimateEndCB;
MemCpy(font,gr_font,256*8);
gr_font=font;
MemCpy(font,text.font,256*8);
text.font=font;
while (TRUE) {
MemCpy(font+CH_SPACE*FONT_HEIGHT,waves+8*(i++&0x3),8);
Sleep(100);
}
}
Spawn(&AnimateTask,NULL,"Animate",,Fs);
TaskRep;
+2 -3
View File
@@ -93,7 +93,7 @@ U0 TreeCommonAncestorFind(Node *root)
}
U0 TreeCommonAncestor()
{ //Make tree and find common ancestor to n1 & n2.
{//Make tree and find common ancestor to n1 & n2.
root=NULL;
n1=n2=common_ancestor=0;
@@ -111,8 +111,7 @@ U0 TreeCommonAncestor()
}
TreeCommonAncestor;
/*
Be careful with recursive routines in TempleOS
/*Be careful with recursive routines in TempleOS
because the stack does not grow and will overflow.
See $LK,"::/Demo/StkGrow.CPP"$.
-16
View File
@@ -1,16 +0,0 @@
U0 Main()
{
CDC *dc=DCAlias;
dc->color=RED+BLACK<<16+ROPF_DITHER;
GrCircle(dc,100,100,50);
GrLine(dc,10,10,280,70);
dc->color=RED+BLUE<<16+ROPF_DITHER;
GrFloodFill(dc,100,100);
dc->color=PURPLE+BLUE<<16+ROPF_DITHER;
GrRect(dc,20,20,100,100);
PressAKey;
DCFill;
DCDel(dc);
}
Main;
+9 -9
View File
@@ -2,11 +2,11 @@
U0 Doodle()
{
I64 msg_code,i,x1,y1,x2,y2,p1,p2,color=BLACK;
I64 msg_code,i,x1,y1,x2,y2,a1,a2,color=BLACK;
CDC *dc=DCAlias;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
WinMax;
WordStat;
@@ -14,7 +14,7 @@ U0 Doodle()
DCFill;
DocClear;
do {
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+
1<<MSG_IP_R_UP);
switch (msg_code) {
@@ -23,23 +23,23 @@ U0 Doodle()
if (i>=0) color=i;
break;
case MSG_IP_L_DOWN:
x1=p1; y1=p2;
x2=p1; y2=p2;
dc->color=ROP_XOR+color^COLOR_TRANSPARENT;
x1=a1; y1=a2;
x2=a1; y2=a2;
dc->color=ROP_XOR+color^TRANSPARENT;
dc->pen_width=1;
while (msg_code!=MSG_IP_L_UP) {
GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
GrLine3(dc,x1,y1,0,x2,y2,0);
x2=p1; y2=p2;
x2=a1; y2=a2;
}
GrLine3(dc,x1,y1,0,x2,y2,0);
break;
case MSG_KEY_DOWN:
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
} while (msg_code!=MSG_KEY_DOWN || !a1);
GetMsg(,,1<<MSG_KEY_UP);
DCFill;
DCDel(dc);
Binary file not shown.
Binary file not shown.
+29 -29
View File
@@ -1,17 +1,17 @@
//After making a font, you can save it as a binary
//file with:
// FileWrite("filename.BIN.Z",gr_font,256*FONT_HEIGHT);
//You can load it with:
// U8 *myfont=FileRead("filename.BIN");
// gr_font=myfont; //preserve gr_font if you want to go back.
/*After making a font, you can save it as a binary
file with:
FileWrite("filename.BIN.Z",text.font,256*FONT_HEIGHT);
You can load it with:
U8 *myfont=FileRead("filename.BIN");
text.font=myfont; //preserve text.font if you want to go back.
//If you want to change the system font permanently,
//save to a file with this font editor program
//and cut and paste the code into $LK,"::/Kernel/Font8x8.CPP"$.
//You will need to recompile Kernel by calling $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$().
If you want to change the system font permanently,
save to a file with this font editor program
and cut and paste the code into $LK,"::/Kernel/Font8x8.CPP"$.
You will need to recompile Kernel by calling $LK,"MakeOSPrtBootInstall",A="MN:MakeOSPrtBootInstall"$().
//See $LK,"::/Demo/ExtendedChars.CPP"$ and
//$LK,"::/Demo/ScreenCodes.CPP"$.
See $LK,"::/Demo/ExtendedChars.CPP"$ and $LK,"::/Demo/ScreenCodes.CPP"$.
*/
#define BLOW_UP_CHAR_X (18*FONT_WIDTH)
#define BLOW_UP_CHAR_Y (2*FONT_HEIGHT)
@@ -31,13 +31,13 @@ U0 DrawIt(CTask *task,CDC *dc)
c=(YELLOW<<4+BLUE)<<8 + k++;
} else
c=(BLUE<<4+WHITE)<<8 + k++;
PlotWinU8(task,c,j,i);
TextChar(task,,j,i,c);
}
k=0;
for (i=0;i<FONT_HEIGHT;i++)
for (j=0;j<FONT_WIDTH;j++) {
if (Bt(&gr_font[FONT_HEIGHT*cur_ch],k++))
if (Bt(&text.font[FONT_HEIGHT*cur_ch],k++))
dc->color=YELLOW;
else
dc->color=BLUE;
@@ -54,7 +54,7 @@ U0 FESave(Bool pmt)
I64 i,j,k=0;
for (i=0;i<256;i++) {
for (j=0;j<FONT_HEIGHT;j++)
DocPrint(doc,"0x%02X,",gr_font[k++]);
DocPrint(doc,"0x%02X,",text.font[k++]);
if (Bt(chars_bitmap_safe_dollar,i))
DocPrint(doc,"//%c",i);
else if (i=='$$')
@@ -69,7 +69,7 @@ U0 FESave(Bool pmt)
U0 FontEd()
{
I64 msg_code,p1,p2,k;
I64 msg_code,a1,a2,k;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
MenuPush(
"File {"
@@ -85,11 +85,11 @@ U0 FontEd()
try {
Fs->draw_it=&DrawIt;
while (TRUE) {
switch (msg_code=GetMsg(&p1,&p2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_MOVE)) {
switch (msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_MOVE)) {
case MSG_KEY_DOWN:
switch (p1) {
switch (a1) {
case 0:
switch (p2.u8[0]) {
switch (a2.u8[0]) {
case SC_CURSOR_LEFT:
cur_ch--;
break;
@@ -114,24 +114,24 @@ U0 FontEd()
case CH_SHIFT_ESC:
goto fe_done;
default:
cur_ch=p1;
cur_ch=a1;
}
break;
case MSG_IP_L_DOWN:
case MSG_IP_R_DOWN:
if (0<=p1<FONT_WIDTH*16 &&
0<=p2<FONT_HEIGHT*16) {
cur_ch=(p2/FONT_HEIGHT)*16+p1/FONT_WIDTH;
if (0<=a1<FONT_WIDTH*16 &&
0<=a2<FONT_HEIGHT*16) {
cur_ch=(a2/FONT_HEIGHT)*16+a1/FONT_WIDTH;
break;
} //fall through
case MSG_IP_MOVE:
k=((p2-BLOW_UP_CHAR_Y)/FONT_HEIGHT)*FONT_WIDTH+
(p1-BLOW_UP_CHAR_X)/FONT_WIDTH;
k=((a2-BLOW_UP_CHAR_Y)/FONT_HEIGHT)*FONT_WIDTH+
(a1-BLOW_UP_CHAR_X)/FONT_WIDTH;
if (0<=k<FONT_WIDTH*FONT_HEIGHT) {
if (ip_lb||msg_code==MSG_IP_L_DOWN)
Bts(&gr_font[FONT_HEIGHT*cur_ch],k);
if (ip_rb||msg_code==MSG_IP_R_DOWN)
Btr(&gr_font[FONT_HEIGHT*cur_ch],k);
if (ip.lb||msg_code==MSG_IP_L_DOWN)
Bts(&text.font[FONT_HEIGHT*cur_ch],k);
if (ip.rb||msg_code==MSG_IP_R_DOWN)
Btr(&text.font[FONT_HEIGHT*cur_ch],k);
}
break;
}
+1 -1
View File
@@ -130,7 +130,7 @@ U0 Hanoi()
MoveDisks(0,2,NUM_DISKS);
Beep; Beep;
DocClear;
"$$CM+BY,0,0$$";
DocBottom;
PressAKey;
} catch
PutExcept;
+2 -2
View File
@@ -1,7 +1,7 @@
U0 InputPointer()
{
while (!ip_lb) //Left Button
GrPlot(,ipx,ipy);
while (!ip.lb) //Left Button
GrPlot(,ip.pos.x,ip.pos.y);
DCFill;
}
+10 -10
View File
@@ -30,7 +30,7 @@ start_over:
GrPlot(dc[next_dc],x,y);
}
} else {
// if (cnt==3) { //Use this for the classic rules
// if (cnt==3) {//Use this for the classic rules
if (cnt==2) {
dc[next_dc]->color=GREEN;
GrPlot(dc[next_dc],x,y);
@@ -46,7 +46,7 @@ start_over:
public U0 Life()
{
I64 msg_code,cnt,x1,y1,x2,y2,p1,p2;
I64 msg_code,cnt,x1,y1,x2,y2,a1,a2;
dc[0]=DCNew(GR_WIDTH,GR_HEIGHT);
dc[1]=DCNew(GR_WIDTH,GR_HEIGHT);
@@ -61,33 +61,33 @@ public U0 Life()
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
WordStat;
Fs->draw_it=&DrawIt;
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
do {
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN);
switch (msg_code) {
case MSG_IP_L_DOWN:
x1=p1; y1=p2;
x2=p1; y2=p2;
x1=a1; y1=a2;
x2=a1; y2=a2;
cnt=0;
while (msg_code!=MSG_IP_L_UP) {
restart=TRUE;
dc[cur_dc]->color=GREEN;
dc[cur_dc]->pen_width=0.04*ip_speed;
dc[cur_dc]->pen_width=0.04*ip.speed;
GrLine3(dc[cur_dc],x1,y1,0,x2,y2,0);
restart=TRUE;
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
x1=x2; y1=y2;
x2=p1; y2=p2;
x2=a1; y2=a2;
}
GrLine3(dc[cur_dc],x1,y1,0,x2,y2,0);
break;
case MSG_KEY_DOWN:
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
} while (msg_code!=MSG_KEY_DOWN || !a1);
GetMsg(,,1<<MSG_KEY_UP);
SettingsPop;
DCFill;
-50
View File
@@ -1,50 +0,0 @@
$SP,"",BI=1,BP="::/Misc/StockSprites.TXT,TempleOSLogo"$
U0 Logo()
{
CDC *dc=DCAlias;
dc->flags|=DCF_TRANSFORMATION;
DocClear;
while (!ScanChar) {
dc->x=Fs->pix_width>>1;
dc->y=Fs->pix_height>>1;
//$LK,"Wrap",A="MN:Wrap"$() converts an angle to an
//equivalent angle in a range starting
//from [arg2,arg2+ã*2).
GrIdentEqu(dc->r);
GrRotYEqu(dc->r,Wrap(tS,-ã/2));
GrRotXEqu(dc->r,30.0*ã/180);
GrSetRotMat(dc,dc->r);
Sprite3(dc,0,0,0,$IB,"<1>",BI=1$);
//See also $LK,"SpriteX3B",A="MN:SpriteX3B"$(),
//$LK,"SpriteY3B",A="MN:SpriteY3B"$(),$LK,"SpriteZ3B",A="MN:SpriteZ3B"$().
WinMgrSync;
DCFill(dc);
}
DCDel(dc);
}
Logo;
+2 -2
View File
@@ -1,10 +1,10 @@
F64 MySin(F64 d)
{
{ //Sin() does not have an address.
return Sin(d);
}
F64 MyCos(F64 d)
{
{ //Cos() does not have an address.
return Cos(d);
}
-24
View File
@@ -1,24 +0,0 @@
/*
$LK,"gr_dc",A="MN:gr_dc"$ is the persistent layer. You can access
it directly but two tasks accessing it simultaneously
with no $LK,"DCAlias",A="MN:DCAlias"$() will screw-up color and stuff.
*/
U0 Moon()
{
I64 i;
for (i=0;i<0x8000;i+=0x200) {
gr_dc->color=BLACK;
GrCircle(gr_dc,300,300,100);
GrCircle(gr_dc,250,300,120,,-.32*pi,0.64*pi);
gr_dc->color=ROPF_PROBABILITY_DITHER+LTGRAY<<16+BLUE;
gr_dc->dither_probability_u16=i;
GrFloodFill(gr_dc,250,300);
gr_dc->dither_probability_u16=2*i;
GrFloodFill(gr_dc,370,300);
WinMgrSync; //Typically 60 fps or 16.6mS
DCFill;
}
}
Moon;
Binary file not shown.
@@ -1,10 +1,10 @@
//Press F5 to compile and run
//Press <F5> to compile and run.
U0 DotNet()
U0 NetOfDots()
{
I64 i;
CDC *dc=DCAlias;
DocClear; //Clear text
DocClear;
dc->color=RED;
for (i=0;i<480;i+=20)
GrLine(dc,i,0,0,480-i,3);
@@ -13,4 +13,4 @@ U0 DotNet()
DCFill;
}
DotNet; //Run when #included
NetOfDots; //Run when #included
+6 -6
View File
@@ -2,32 +2,32 @@ U0 PanText()
{
I64 i;
for (i=0;i<=7;i++) {
gr_pan_text_x=i;
gr.pan_text_x=i;
Sleep(30);
}
i--;
for (;i>=-7;i--) {
gr_pan_text_x=i;
gr.pan_text_x=i;
Sleep(30);
}
i++;
for (;i<=0;i++) {
gr_pan_text_x=i;
gr.pan_text_x=i;
Sleep(30);
}
for (i=0;i<=7;i++) {
gr_pan_text_y=i;
gr.pan_text_y=i;
Sleep(30);
}
i--;
for (;i>=-7;i--) {
gr_pan_text_y=i;
gr.pan_text_y=i;
Sleep(30);
}
i++;
for (;i<=0;i++) {
gr_pan_text_y=i;
gr.pan_text_y=i;
Sleep(30);
}
}
Binary file not shown.
Binary file not shown.
+11 -11
View File
@@ -37,7 +37,7 @@ F64 F(Complex *x)
CDiv(&num,&denom,&n1);
R2P(&m,&a,n1.x,n1.y);
if (ip_rb)
if (ip.rb)
return ã+a;
else
return m;
@@ -94,7 +94,7 @@ U0 Draw()
U0 PoleZeros()
{
I64 msg_code,p1,p2,p11,p22,cx,cy;
I64 msg_code,a1,a2,p11,p22,cx,cy;
Complex *tempc=NULL;
PopUpOk(
@@ -104,7 +104,7 @@ U0 PoleZeros()
WinMgrSync;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
SetVGAPalette4(vga_palette4_gray);
SetVGAPaletteColor(15,0xFF0000); //White is red
@@ -119,21 +119,21 @@ U0 PoleZeros()
try {
Draw;
while (TRUE) {
msg_code=GetMsg(&p1,&p2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_L_UP+1<<MSG_IP_R_DOWN+1<<MSG_IP_R_UP+1<<MSG_IP_MOVE);
msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_L_UP+1<<MSG_IP_R_DOWN+1<<MSG_IP_R_UP+1<<MSG_IP_MOVE);
pz_msg:
cx=Fs->pix_width/2;
cy=Fs->pix_height/2;
switch (msg_code) {
case MSG_IP_L_DOWN:
tempc=PoleZeroFind(p1-cx,cy-p2);
tempc=PoleZeroFind(a1-cx,cy-a2);
break;
case MSG_IP_MOVE:
if (tempc) {
p11=p1;p22=p2;
p11=a1;p22=a2;
//get to last mouse move
while (msg_code=ScanMsg(&p1,&p2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_L_UP+1<<MSG_IP_R_DOWN+1<<MSG_IP_R_UP+1<<MSG_IP_MOVE))
while (msg_code=ScanMsg(&a1,&a2,1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+1<<MSG_IP_L_UP+1<<MSG_IP_R_DOWN+1<<MSG_IP_R_UP+1<<MSG_IP_MOVE))
if (msg_code==MSG_IP_MOVE) {
p11=p1;p22=p2;
p11=a1;p22=a2;
} else
goto pz_msg;
@@ -144,8 +144,8 @@ pz_msg:
break;
case MSG_IP_L_UP:
if (tempc) {
tempc->x=p1-cx;
tempc->y=cy-p2;
tempc->x=a1-cx;
tempc->y=cy-a2;
tempc=NULL;
Draw;
}
@@ -155,7 +155,7 @@ pz_msg:
Draw;
break;
case MSG_KEY_DOWN:
if (p1==CH_SHIFT_ESC||p1==CH_ESC)
if (a1==CH_SHIFT_ESC||a1==CH_ESC)
goto pz_done;
}
WinMgrSync;
+1 -1
View File
@@ -1,4 +1,4 @@
//This is a classic 2nd order nonlinear ordinary differential equation
//Classic 2nd order nonlinear ordinary differential equation
I64 mp_not_done_flags;
Binary file not shown.
Binary file not shown.
+4 -7
View File
@@ -1,7 +1,7 @@
//"ls" is light source.
U0 Lighting(CDC *dc,CD3I32 *ls,CD3I32 *poly,I64 color)
{ //color is a color from 0-7
{//color is a color from 0-7
CD3I32 v1,v2;
I64 *r=dc->r,i,vn_x,vn_y,vn_z;
F64 d;
@@ -36,7 +36,6 @@ U0 Lighting(CDC *dc,CD3I32 *ls,CD3I32 *poly,I64 color)
//vect and the surface normal
//gives an illumination number.
//TempleOS will generate a random U16
//and compare to dither_probability_u16 and
//will pick from two colors.
@@ -73,21 +72,19 @@ U0 DrawIt(CTask *task,CDC *dc)
GrScaleEqu(dc->r,tt);
GrSetRotMat(dc,dc->r);
ls.x=-(ipx-task->pix_left-task->scroll_x-cx);
ls.y=-(ipy-task->pix_top-task->scroll_y-cy);
ls.x=-(ip.pos.x-task->pix_left-task->scroll_x-cx);
ls.y=-(ip.pos.y-task->pix_top-task->scroll_y-cy);
ls.z=GR_WIDTH/8;
d=1<<16/D3I32Norm(&ls);
ls.x*=d;
ls.y*=d;
ls.z*=d;
dc->x=cx;
dc->y=cy;
dc->z=MaxI64(cx,cy);
radius =MinI64(cx,cy)/2;
for (i=0;i<RINGS;i++) {
è = i*ã/2/RINGS;
è2=(i+1)*ã/2/RINGS+SLOP;
@@ -151,7 +148,7 @@ U0 DrawIt(CTask *task,CDC *dc)
//See $LK,"::/Demo/Graphics/SpritePlot3D.CPP"$.
//for a CSprite example.
//See $LK,"SpriteMesh",A="MN:SpriteMesh"$() for a fancy example.
//See $LK,"SpriteMeshEd",A="MN:SpriteMeshEd"$() for a fancy example.
U0 Main()
{
Binary file not shown.
+3 -4
View File
@@ -1,12 +1,11 @@
/*
This was done with <CTRL-SHIFT-L> managed code.
/*This was done with <CTRL-SHIFT-L> template code.
It's conceptually easy to do a ctrl,
but tedious. You have complete freedom.
See $LK,"CCtrl",A="MN:CCtrl"$.
*/
// Start of autocreated Code
//Start of autocreated Code
#define SLIDER_RANGE 30
#define SLIDER_SPACING 20
#define SLIDER_BORDER 2
@@ -94,7 +93,7 @@ U0 SliderDel(CCtrl *c)
Free(c);
}
// End of autocreated Code
//End of autocreated Code
U0 Main()
{
+9 -9
View File
@@ -2,12 +2,12 @@
public U0 SpeedLineDemo()
{
I64 msg_code,cnt,x1,y1,x2,y2,p1,p2,color=BLACK;
I64 msg_code,cnt,x1,y1,x2,y2,a1,a2,color=BLACK;
CDC *dc=DCAlias;
dc->color=color;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
WinMax;
WinBorder;
@@ -15,7 +15,7 @@ public U0 SpeedLineDemo()
DCFill;
DocClear;
do {
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+
1<<MSG_IP_R_UP);
switch (msg_code) {
@@ -25,23 +25,23 @@ public U0 SpeedLineDemo()
dc->color=color;
break;
case MSG_IP_L_DOWN:
x1=p1; y1=p2;
x2=p1; y2=p2;
x1=a1; y1=a2;
x2=a1; y2=a2;
cnt=0;
while (msg_code!=MSG_IP_L_UP) {
dc->pen_width=0.04*ip_speed;
dc->pen_width=0.04*ip.speed;
GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
x1=x2; y1=y2;
x2=p1; y2=p2;
x2=a1; y2=a2;
}
GrLine3(dc,x1,y1,0,x2,y2,0);
break;
case MSG_KEY_DOWN:
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
} while (msg_code!=MSG_KEY_DOWN || !a1);
GetMsg(,,1<<MSG_KEY_UP);
DCFill;
DCDel(dc);
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -8
View File
@@ -1,18 +1,16 @@
/*
If you press <CTRL-T> you will see this:
/*If you press <CTRL-t> you will see this:
$$IB+BP,"<1>",1,"::/Demo/Graphics/SpritePut.CPP,2"$$
$$IB,"<1>",BI=1,BP="::/Demo/Graphics/SpritePut.CPP,2"$$
That imports an external sprite. It's
called a $LK,"DOCEF1_BIN_PTR_LINK",A="MN:DOCEF1_BIN_PTR_LINK"$.
called a $LK,"DOCEF_BIN_PTR_LINK",A="MN:DOCEF_BIN_PTR_LINK"$. See $LK,"BP=\"\"",A="FF:::/Doc/DolDocOverview.TXT,BP=\"\""$.
Press <CTRL-R> and "pointer to sprite".
Press <CTRL-r> and "pointer to sprite".
Then, enter a file and the number of
the sprite in the file. Note: the
number can get messed-up if you change
the order of sprites in the source file.
You can enter a tag instead of a num.
You can link to a tag string instead of a num.
*/
U0 SpritePutExt()
@@ -21,7 +19,7 @@ U0 SpritePutExt()
for (i=0;i<3;i++) {
"US Map:";
Sprite($IB,"<1>",BI=1,BP="::/Demo/Graphics/SpritePut.CPP,2"$);
NewLine(12);
"%h12c",'\n';
}
}
Binary file not shown.
+43
View File
@@ -0,0 +1,43 @@
/*$LK,"gr.dc",A="MN:CGrGlbls"$ is the persistent layer. You can access
it directly but two tasks accessing it simultaneously
with no $LK,"DCAlias",A="MN:DCAlias"$() will screw-up color and stuff.
*/
U0 SunMoon()
{
I64 i,x,y,radius;
WinMax; //Maximize window
DocClear; //Clear command-line text
WinBorder; //No Border
WordStat; //WordStat Off
Fs->text_attr=BLACK<<+WHITE; //Current $LK,"CTask",A="MN:CTask"$ is Fs segment register.
for (i=0;i<0x8000;i+=0x200) {
//Sun
x=0.2*GR_WIDTH; y=0.5*GR_HEIGHT; radius=120;
gr.dc->color=DKGRAY;
GrCircle(gr.dc,x,y,radius);
gr.dc->color=ROPF_DITHER+RED<<16+YELLOW;
GrFloodFill(gr.dc,x,y);
//Moon
x=0.8*GR_WIDTH-i/0x200; y=0.5*GR_HEIGHT; radius=75;
gr.dc->color=DKGRAY;
GrCircle(gr.dc,x,y,radius);
//<CTRL-ALT-a> for the "ã" character.
GrCircle(gr.dc,x+0.5*radius,y,1.2*radius,,ã-.31*ã,0.62*ã);
gr.dc->color=ROPF_PROBABILITY_DITHER+LTGRAY<<16+BLACK;
gr.dc->dither_probability_u16=i; //U16 can be [0,65535]
GrFloodFill(gr.dc,x+0.5*radius,y);
gr.dc->dither_probability_u16=2*i; //U16 can be [0,65535]
GrFloodFill(gr.dc,x-0.75*radius,y);
WinMgrSync; //Typically 60 fps or 16.6mS
DCFill;
}
Fs->text_attr=WHITE<<4+BLUE;
}
SunMoon;
+18 -17
View File
@@ -1,14 +1,15 @@
//This is demonstrates symmetry.
//Right-click and draw line of symmetry.
//If the line of symmetry is a point, symmetry is turned-off.
/*Demonstrates symmetry.
Right-click and draw line of symmetry.
If the line of symmetry is a point, symmetry is turned-off.
*/
U0 SymmetryDemo()
{
I64 msg_code,x1,y1,x2,y2,p1,p2;
I64 msg_code,x1,y1,x2,y2,a1,a2;
CDC *dc=DCAlias;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
Fs->win_inhibit=WIG_TASK_DFT-WIF_FOCUS-WIF_BORDER;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
WinMax;
DCFill;
@@ -16,43 +17,43 @@ U0 SymmetryDemo()
dc->flags|=DCF_SYMMETRY;
GrSetSymmetry(dc,Fs->pix_width/2,0,Fs->pix_width/2,1);
do {
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_KEY_DOWN+1<<MSG_IP_L_DOWN+
1<<MSG_IP_R_DOWN);
switch (msg_code) {
case MSG_IP_R_DOWN:
dc->flags&=~DCF_SYMMETRY;
dc->color=ROP_XOR+RED^COLOR_TRANSPARENT;
x1=p1; y1=p2;
x2=p1; y2=p2;
dc->color=ROP_XOR+RED^TRANSPARENT;
x1=a1; y1=a2;
x2=a1; y2=a2;
while (msg_code!=MSG_IP_R_UP) {
GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_R_UP+1<<MSG_IP_MOVE);
GrLine3(dc,x1,y1,0,x2,y2,0);
x2=p1; y2=p2;
x2=a1; y2=a2;
}
GrLine3(dc,x1,y1,0,x2,y2,0);
if (GrSetSymmetry3(dc,x1,y1,0,x2,y2,0,x2,y2,1))
dc->flags|=DCF_SYMMETRY;
break;
case MSG_IP_L_DOWN:
dc->color=ROP_XOR+BLACK^COLOR_TRANSPARENT;
x1=p1; y1=p2;
x2=p1; y2=p2;
dc->color=ROP_XOR+BLACK^TRANSPARENT;
x1=a1; y1=a2;
x2=a1; y2=a2;
while (msg_code!=MSG_IP_L_UP) {
GrLine3(dc,x1,y1,0,x2,y2,0);
msg_code=GetMsg(&p1,&p2,
msg_code=GetMsg(&a1,&a2,
1<<MSG_IP_L_UP+1<<MSG_IP_MOVE);
GrLine3(dc,x1,y1,0,x2,y2,0);
x2=p1; y2=p2;
x2=a1; y2=a2;
}
GrLine3(dc,x1,y1,0,x2,y2,0);
break;
case MSG_KEY_DOWN:
break;
}
} while (msg_code!=MSG_KEY_DOWN || !p1);
} while (msg_code!=MSG_KEY_DOWN || !a1);
GetMsg(,,1<<MSG_KEY_UP);
DCFill;
DCDel(dc);
Binary file not shown.
+8 -3
View File
@@ -1,5 +1,4 @@
/*
This was done with <CTRL-SHIFT-L> managed code
/*Done with <CTRL-SHIFT-L> template code
that was modified.
This is an advanced demo that shows
@@ -76,7 +75,13 @@ U0 LeftClickSlider(CCtrl *c,I64 x,I64 y,Bool)
CCtrl *SliderNew()
{
Bool old_preempt;
CCtrl *c=ACAlloc(sizeof(CCtrl));
CCtrl *c;
if (Fs!=adam_task) {
"Must be Adam Included with SHIFT-F5.\n"
"(Would crash when code mem was freed.)\n";
return NULL;
}
c=ACAlloc(sizeof(CCtrl));
c->win_task=sys_winmgr_task;
c->flags=CTRLF_SHOW|CTRLF_CAPTURE_LEFT_IP;
c->type=CTRLT_GENERIC;
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
U0 DrawIt(CTask *,CDC *dc)
{
I64 i,j;
U16 *ptr=gr_win_z_buf;
U16 *ptr=gr.win_z_buf;
dc->color=BLACK;
GrPrint(dc,0,0,"Move the windows around and watch.");
for (i=0;i<TEXT_ROWS;i++)