Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Chris Warren-Smith cwarrensmith@gmail.com chrisws
Nicholas Christopoulos wired_gr@yahoo.com ndc
Gary A. Clark clarkg@fireserve.net gac
Bob Riess riessb@usa.net bob
Earle F. Philhower III earle@ziplabel.com efp
Laurent Poujoulat lpoujoulat@wanadoo.fr lap
Mehul Sanghvi mehul.sanghvi@gmail.com mnsanghvi


Chris Warren-Smith cwarrensmith@gmail.com chrisws
Nicholas Christopoulos wired_gr@yahoo.com ndc
Gary A. Clark clarkg@fireserve.net gac
Bob Riess riessb@usa.net bob
Earle F. Philhower III earle@ziplabel.com efp
Laurent Poujoulat lpoujoulat@wanadoo.fr lap
Mehul Sanghvi mehul.sanghvi@gmail.com mnsanghvi
Joerg Siebenmorgen siebenmorgen@mailbox.org j7m
16 changes: 16 additions & 0 deletions samples/distro-examples/examples/ticks.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
print "step | ticks"
print "--------------|----------"

print "initial ticks | "; ticks()
delay(100)
print "delay(100) | "; ticks()

ticks(0)
print "ticks(0) | "; ticks()
delay(100)
print "delay(100) | "; ticks()

ticks(1000)
print "ticks(1000) | "; ticks()
delay(100)
print "delay(100) | "; ticks()
4 changes: 2 additions & 2 deletions samples/distro-examples/tests/all.bas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ print "CHDIR:" ':CHDIR dir
print "CHMOD:" ':CHMOD file, mode
print "CIRCLE:" ':CIRCLE [STEP] x,y,r [,aspect [, color]] [COLOR color] [FILLED]
print "CLOSE:" ':CLOSE #fileN
print "CLS:" :CLS
print "CLS:"' :CLS
print "COLOR:" :COLOR 1,2
print "COPY:" ':COPY "file", "newfile"
print "DATEDMY:";: DATEDMY(2459590,jd,jm,jy): print jd;jm;jy
Expand Down Expand Up @@ -230,7 +230,7 @@ print "TAN:" + TAN (x)
print "TANH:" + TANH (x)
print "TEXTHEIGHT:" + TEXTHEIGHT (s)
print "TEXTWIDTH:" + TEXTWIDTH (s)
print "TICKS:"' + TICKS
print "TICKS:": TICKS(0): if(TICKS()) then throw "Ticks failed"
print "TIME:"' + TIME
print "TIMER:"' + TIMER
print "TIMESTAMP:" '+ TIMESTAMP filename
Expand Down
17 changes: 17 additions & 0 deletions src/common/blib.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#define STR_INIT_SIZE 256
#define PKG_INIT_SIZE 5

// ticks(n)
extern var_int_t tickOffset;

/**
* LET v[(x)] = any
* CONST v[(x)] = any
Expand Down Expand Up @@ -2374,6 +2377,20 @@ void cmd_environ() {
v_free(&str);
}

/**
* TICKS int
*/
void cmd_ticks(void) {
var_int_t offset;

offset = par_getint();
if (prog_error) {
return;
}

tickOffset = dev_get_millisecond_count() - offset;
}

/**
* DATEDMY string|julian, m, d, y
*/
Expand Down
1 change: 1 addition & 0 deletions src/common/blib.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void cmd_datedmy(void);
void cmd_timehms(void);
void cmd_deriv(void);
void cmd_diffeq(void);
void cmd_ticks(void);

// not basic, but speed is needed
void graph_reset(void);
Expand Down
5 changes: 4 additions & 1 deletion src/common/blib_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ static char *date_wdN_table[] = TABLE_WEEKDAYS_FULL;
static char *date_m3_table[] = TABLE_MONTH_3C;
static char *date_mN_table[] = TABLE_MONTH_FULL;

// ticks()
var_int_t tickOffset = 0;

#define BUF_LEN 64
#define BIN_LEN 32 // Number of max bits (digits) kwBIN creates

Expand Down Expand Up @@ -752,7 +755,7 @@ var_int_t cmd_imath0(long funcCode) {
//
// int <- TICKS // clock()
//
r = dev_get_millisecond_count();
r = dev_get_millisecond_count() - tickOffset;
break;
case kwPROGLINE:
//
Expand Down
3 changes: 3 additions & 0 deletions src/common/brun.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ static inline void bc_loop_call_proc() {
case kwAT:
cmd_at();
break;
case kwTICKSP:
cmd_ticks();
break;
case kwPEN:
cmd_pen();
break;
Expand Down
3 changes: 2 additions & 1 deletion src/common/kw.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ enum proc_keywords {
kwDEFINEKEY,
kwSHOWPAGE,
kwTHROW,
kwNULLPROC
kwNULLPROC,
kwTICKSP
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/languages/keywords.en.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ struct proc_keyword_s proc_table[] = {
{ "CALL", kwCALLCP },
{ "DEFINEKEY", kwDEFINEKEY },
{ "SHOWPAGE", kwSHOWPAGE },
{ "TIMER", kwTIMER },
{ "TIMER", kwTIMER },
{ "TICKS", kwTICKSP },

#if !defined(OS_LIMITED)
{ "STKDUMP", kwSTKDUMP },
Expand Down