Enjoy programming more!
Kidspod is a post site which supports young programmers.
First step to join us.
Register as a member
For members

2020/03/15 18:46:14

MixJuice GET URL : kidspod.club/mj/952

pancakeカラースタンプエディタ

  • No registered tag exist.

SOURCE CODE

// COLOR STAMP
var x=0,y=0;
uart(128,4,0,15);

function line(o){
uart(128,8,1,x,y,x,y,o);
}

function co(d){
var o;
 if(x%2>0){
o=d%16;
 }else{
o=d/16;
 }
return o;
}

function cd(d,o){
var e;
 if(x%2>0){
e=d-d%16+o;
 }else{
e=o*16+d%16;
 }
return e;
}

function key(k){
var d,o,adr,i,w=0;
adr=x/8*32+x%8/2+y%16/8*320+y%8*4+mem("s");
 if((58>k)*(k>47)){
o=k-48;
d=cd(mem(adr),o);
mem(adr,d);
 }
 if((103>k)*(k>96)){
o=k-87;
d=cd(mem(adr));
mem(adr,d);
 }
 if(k>102){
adr=(k-103)*32;
stp(adr);
 }
 if(k==87){
w=1;
adr=x/8*32+y/8*320;
put(adr,w);
 }
 if(k==82){
w=0;
adr=x/8*32+y/8*320;
put(adr,w);
 }
d=mem(adr);
 if((k==28)*(x>0)){
o=co(d);line(o);x=x-1;
 }
 if((k==29)*(x<79)){
o=co(d);line(o);x=x+1;
 }
 if((k==30)*(y>0)){
o=co(d);line(o);y=y-1;
 }
 if((k==31)*(y<44)){
o=co(d);line(o);y=y+1;
 }
line(1);
beep((x%8<1)+(y%8<1));
}


function put(adr,w){
var d,h,l,i=0,edd=2048*49,n;
 while(i<32){
d=0x50|(((adr+edd>>16)&1)<<2);
h=((adr+edd)&0xff00)>>8;
l=(adr+edd)&0xff;
  if(w<1){
i2cw(d,h,l);
sleep(30);
i2cr(d,n);
mem(mem("s")+adr%640,n);
  }
  if(w>0){
n=mem(mem("s")+adr%640);
i2cw(d,h,l,n);
sleep(30);
  }
i=i+1;
adr=adr+1;
 }
x=x/8*8;y=y/8*8;
stp((adr-32)%640);
}


function stp(adr){
uart(128,38,2,x,y,15);
i=0;
 while(i<32){
uart(mem(mem("s")+adr+i));
i=i+1;
 }
}

 function main(){
line(env()&1);
env(env()+1);
setTout(main,300);
 }

setKprs(key);
main();

COMMENT