Commit 2e0417af authored by Alexander Shabarshin's avatar Alexander Shabarshin

Circuits.CC v0.2

parent cfde1266
Lib/Brd/Macros/ CAPA SMD1 SMD2
Lib/Brd/SIP/ 1
Lib/Brd/DIP/ 2
Lib/Brd/SOIC/ 3
Lib/Brd/PLCC/ PLCC32 PLCC84
Lib/Brd/Examples RS232_TTL
Lib/Sch/Macros/ PWR GND NEG_PWR PWR5V PWR3V RES CAP CAP_EL
Lib/Sch/Logic/ NOT OR2 AND2 NAND2 XOR OR3 AND3 OR4 AND4 MUX2
Lib/Sch/BigLogic DTRIG_RS
Lib/Ternary/ MUX3 TRIMUX_SCH TRIMUX TRI_1L TRI_2L
Lib/Clipboard/ 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char **argv)
{
int i,sz,ft=0;
unsigned char b;
char str[100],*po;
FILE *fi,*fo;
if(argc>2 && argv[2][0]=='t') ft=1;
fi = fopen(argv[1],"rb");
if(fi==NULL) return -1;
strcpy(str,argv[1]);
po = strrchr(str,'.');
if(po!=NULL) *po = 0;
strcat(str,".txt");
fo = fopen(str,"wt");
if(fo==NULL)
{
fclose(fi);
return -2;
}
fseek(fi,0,SEEK_END);
sz = ftell(fi);
fseek(fi,0,SEEK_SET);
for(i=0;i<sz;i++)
{
b = fgetc(fi);
if(ft)
{
if(b==0x0D) continue;
if(b==0x0A) b=0;
}
fprintf(fo,"%i",b);
if(i<sz-1) fprintf(fo,",");
}
fclose(fo);
fclose(fi);
return 0;
}
rw1c -p -l -r -d circuits.rw1
echo var robot = >circuits.js
cat circuits.rjs >>circuits.js
cp circuits.js /var/www/htdocs/pcb
This diff is collapsed.
// Roberta language common definitions
// Compatible with RW1C v2.2.0 and above
// See http://rwar.net for more info
@if(3)=((@1)?(@2):(@3))
@max(2)=(((@1)>(@2))?(@1):(@2))
@min(2)=(((@1)<(@2))?(@1):(@2))
@abs(1)=(((@1)<0)?(-(@1)):(@1))
@sqr(1)=((@1)*(@1))
@mod(2)=((@1)%(@2))
@and(2)=((@1)&&(@2))
@or(2)=((@1)||(@2))
@not(1)=(!(@1))
@neg(1)=(-(@1))
// System event identifiers:
@mouse=#FFFF
@keyboard=#FFFE
@select=#FFFD
@filesystem=#FFFC
// System constants
@filebuffer=#8000
// Platform 0 (RW1P0):
@t_empty=0
@t_hole=1
@t_stone=2
@t_box=3
@t_reactor=4
@t_missle=5
@t_robot=6
@t_my=7
@t_wall=10
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* http://webitable.sourceforge.net (E-mail: shaos@users.sourceforge.net)
Webitable System - easily editable web pages for everyone
Copyright (C) 2005-2012 Alexander Shabarshin (ashabarshin@gmail.com)
Copyright (C) 2012 Alexander Shabarshin (ashabarshin@gmail.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -21,9 +22,11 @@
var $W = {
lib_name: "Webitable",
ver_major: 0,
ver_minor: 1,
copyright: "(c) 2005-2012 Alexander Shabarshin",
cache: {}
ver_minor: 2,
copyright: "(c) 2012 Alexander Shabarshin",
cache: {},
threads: [],
started: 0
};
$W.version = function() {
......@@ -117,6 +120,42 @@ $W.table = function(p,h,w,s) {
return r;
}
$W.thread = function(obj) {
var m = this.threads.length;
this.threads[m] = {o:obj,c:[],a:0,p:1};
return m;
}
$W.stop = function() {
if(this.started!=0) {
clearInterval(this.started);
this.started = 0;
}
}
$W.start = function() {
var p = arguments[0]; // percentage
if(p==null) p=16; // 0.8 duty
else p=p/5; // for 20 ms
this.stop();
var sf = "";
for(var t in $W.threads) {
sf += "var t"+t+"=$W.threads["+t+"];if(t"+t+".f) t"+t+".a=t"+t+".f(t"+t+".o);";
}
sf += "var t=+new Date;while(+ new Date-t<"+p+"){";
var i,j=0;
while(j<100) {
for(var t in $W.threads) {
for(i=0;i<$W.threads[t].p;i++) {
sf += "t"+t+".a=t"+t+".c[t"+t+".a](t"+t+".o);";
j++;
}
}
}
sf += "}";
this.started = setInterval(new Function(sf),20);
}
function $(s) {
return document.getElementById(s);
}
......@@ -182,7 +221,7 @@ function $$_(s) {
}
function $time() {
return Math.floor(Date.now()/1000);
return Math.floor(+new Date/1000);
}
function $random(r) {
......@@ -191,16 +230,14 @@ function $random(r) {
function $map(a,f) {
var r = [];
var n = a.length;
for(var i=0;i<n;i++) {
for(var i in a) {
r.push(f(a[i]));
}
return r;
}
function $reduce(a,b,f) {
var n = a.length;
for(var i=0;i<n;i++) {
for(var i in a) {
b = f(b,a[i]);
}
return b;
......@@ -208,11 +245,39 @@ function $reduce(a,b,f) {
function $filter(a,f) {
var r = [];
var n = a.length;
for(var i=0;i<n;i++) {
for(var i in a) {
if(f(a[i])) {
r.push(a[i]);
}
}
return r;
}
function $hex(i,j) {
var k,l,m=1,s="",r=i,g=1;
var h=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
if(r<0) {
g = -1;
r = -i;
}
for(k=1;k<j;k++) {
m = m*16;
}
if(r >= m*16) {
g = 0;
r = r&(m*16-1);
}
for(k=0;k<j;k++) {
l = Math.floor(r/m);
r = r-l*m;
m = m/16;
s += h[l];
}
if(g<0) {
return "-" + s;
}
if(g==0) {
return "~" + s;
}
return s;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment