diff --git a/.gitignore b/.gitignore index 15e2148..71d2561 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ cli/TinyBasicPlus.cpp cli/tbp notes.txt +.DS_Store diff --git a/README.md b/README.md index 036c4b9..3f496e6 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ program. - ECHAIN - load the program from EEProm and run it ## IO, Documentation +- INPUT variable - *let the user input an expression (number or variable name* - PEEK( address ) - *get a value in memory* (unimplemented) - POKE address - *set a value in memory* (unimplemented) - PRINT expression - *print out the expression, also "?"* @@ -85,6 +86,19 @@ NOTE: TONE commands are by default disabled Here are a few example programs to get you started... +## User Input + +Let a user enter a new value for a variable, enter a number like '33' or '42', +or a varaible like 'b'. + + 10 A=0 + 15 B=999 + 20 PRINT "A is ", A + 30 PRINT "Enter a new value "; + 40 INPUT A + 50 PRINT "A is now ", A + + ## Blink hook up an LED between pin 3 and ground @@ -185,6 +199,42 @@ List both, and run # Links - [Arduino Microcontroller](http://arduino.cc) +# Licensing + +Mike Field based his C port of Tiny Basic on the 68000 Tiny BASIC which carried +the following license: + +~~~ +****************************************************************** +* * +* Tiny BASIC for the Motorola MC68000 * +* * +* Derived from Palo Alto Tiny BASIC as published in the May 1976 * +* issue of Dr. Dobb's Journal. Adapted to the 68000 by: * +* Gordon Brandly * +* 12147 - 51 Street * +* Edmonton AB T5W 3G8 * +* Canada * +* (updated mailing address for 1996) * +* * +* This version is for MEX68KECB Educational Computer Board I/O. * +* * +****************************************************************** +* Copyright (C) 1984 by Gordon Brandly. This program may be * +* freely distributed for personal use only. All commercial * +* rights are reserved. * +****************************************************************** +~~~ + +However, Mike did not include a license of his own for his + version of this. From discussions with him, I felt that the MIT license is +the most applicable to his intent. + +I am in the process of further determining what should be done wrt licensing +further. This entire header will likely change with the next version 0.16, +which will hopefully nail down the whole thing so we can get back to +implementing features instead of licenses. Thank you for your time. + # MIT License Copyright (c) 2012-2013 diff --git a/Arduino/TinyBasicPlus.ino b/TinyBasicPlus/TinyBasicPlus.ino similarity index 89% rename from Arduino/TinyBasicPlus.ino rename to TinyBasicPlus/TinyBasicPlus.ino index 1ccc566..cc34578 100644 --- a/Arduino/TinyBasicPlus.ino +++ b/TinyBasicPlus/TinyBasicPlus.ino @@ -2,16 +2,68 @@ // TinyBasic Plus //////////////////////////////////////////////////////////////////////////////// // -// Authors: Mike Field -// Scott Lawrence -// Brian O'Dell +// Authors: +// Gordon Brandly (Tiny Basic for 68000) +// Mike Field (Arduino Basic) (port to Arduino) +// Scott Lawrence (TinyBasic Plus) (features, etc) +// +// Contributors: +// Brian O'Dell (INPUT) +// (full list tbd) + +// For full history of Tiny Basic, please see the wikipedia entry here: +// https://en.wikipedia.org/wiki/Tiny_BASIC + +// LICENSING NOTES: +// Mike Field based his C port of Tiny Basic on the 68000 +// Tiny BASIC which carried the following license: +/* +****************************************************************** +* * +* Tiny BASIC for the Motorola MC68000 * +* * +* Derived from Palo Alto Tiny BASIC as published in the May 1976 * +* issue of Dr. Dobb's Journal. Adapted to the 68000 by: * +* Gordon Brandly * +* 12147 - 51 Street * +* Edmonton AB T5W 3G8 * +* Canada * +* (updated mailing address for 1996) * +* * +* This version is for MEX68KECB Educational Computer Board I/O. * +* * +****************************************************************** +* Copyright (C) 1984 by Gordon Brandly. This program may be * +* freely distributed for personal use only. All commercial * +* rights are reserved. * +****************************************************************** +*/ +// ref: http://members.shaw.ca:80/gbrandly/68ktinyb.html +// +// However, Mike did not include a license of his own for his +// version of this. +// ref: http://hamsterworks.co.nz/mediawiki/index.php/Arduino_Basic +// +// From discussions with him, I felt that the MIT license is +// the most applicable to his intent. +// +// I am in the process of further determining what should be +// done wrt licensing further. This entire header will likely +// change with the next version 0.16, which will hopefully nail +// down the whole thing so we can get back to implementing +// features instead of licenses. Thank you for your time. -#define kVersion "v0.14" +#define kVersion "v0.15" + +// v0.15: 2018-06-23 +// Integrating some contributions +// Corrected some of the #ifdef nesting atop this page +// Licensing issues beginning to be addressed // v0.14: 2013-11-07 -// Input command always set the variable to 99 // Modified Input command to accept an expression using getn() // Syntax is "input x" where x is any variable +// NOTE: This only works for numbers, expressions. not strings. // // v0.13: 2013-03-04 // Support for Arduino 1.5 (SPI.h included, additional changes for DUE support) @@ -77,12 +129,9 @@ // Quirk: "10 LET A=B+C" is ok "10 LET A = B + C" is not. // Quirk: INPUT seems broken? - - // IF testing with Visual C, this needs to be the first thing in the file. //#include "stdafx.h" - char eliminateCompileErrors = 1; // fix to suppress arduino build errors // hack to let makefiles work with this file unchanged @@ -133,131 +182,146 @@ char eliminateCompileErrors = 1; // fix to suppress arduino build errors // Set your console D0/D1 baud rate here (9600 baud default) #define kConsoleBaud 9600 + //////////////////////////////////////////////////////////////////////////////// -#ifdef ARDUINO +// fixes for RAMEND on some platforms #ifndef RAMEND -// okay, this is a hack for now -// if we're in here, we're a DUE probably (ARM instead of AVR) + // RAMEND is defined for Uno type Arduinos + #ifdef ARDUINO + // probably DUE or 8266? + #ifdef ESP8266 + #define RAMEND (8192-1) + #else + // probably DUE - ARM rather than AVR + #define RAMEND (4096-1) + #endif + #endif +#endif -#define RAMEND 4096-1 // Enable memory alignment for certain processers (e.g. some ESP8266-based devices) -// Uses up to one extra byte per program line of memory -#define ALIGN_MEMORY 1 -//#undef ALIGN_MEMORY - -// turn off EEProm -#undef ENABLE_EEPROM -#undef ENABLE_TONES - +#ifdef ESP8266 + // Uses up to one extra byte per program line of memory + #define ALIGN_MEMORY 1 #else -// we're an AVR! - -// we're moving our data strings into progmem -#include + #undef ALIGN_MEMORY #endif -// includes, and settings for Arduino-specific functionality -#ifdef ENABLE_EEPROM -#include /* NOTE: case sensitive */ -int eepos = 0; +#ifndef ARDUINO + // not an arduino, so we can disable these features. + // turn off EEProm + #undef ENABLE_EEPROM + #undef ENABLE_TONES #endif -#ifdef ENABLE_FILEIO -#include -#include /* needed as of 1.5 beta */ - -// Arduino-specific configuration -// set this to the card select for your SD shield -#define kSD_CS 10 +// includes, and settings for Arduino-specific features +#ifdef ARDUINO -#define kSD_Fail 0 -#define kSD_OK 1 + // EEPROM + #ifdef ENABLE_EEPROM + #include /* NOTE: case sensitive */ + int eepos = 0; + #endif -File fp; -#endif + // SD card File io + #ifdef ENABLE_FILEIO + #include + #include /* needed as of 1.5 beta */ -// set up our RAM buffer size for program and user input -// NOTE: This number will have to change if you include other libraries. -#ifdef ARDUINO -#ifdef ENABLE_FILEIO -#define kRamFileIO (1030) /* approximate */ -#else -#define kRamFileIO (0) -#endif -#ifdef ENABLE_TONES -#define kRamTones (40) -#else -#define kRamTones (0) -#endif -#endif /* ARDUINO */ -#define kRamSize (RAMEND - 1160 - kRamFileIO - kRamTones) + // set this to the card select for your Arduino SD shield + #define kSD_CS 10 -#ifndef ARDUINO -// Not arduino setup -#include -#include -#undef ENABLE_TONES + #define kSD_Fail 0 + #define kSD_OK 1 -// size of our program ram -#define kRamSize 4096 /* arbitrary */ + File fp; + #endif -#ifdef ENABLE_FILEIO -FILE * fp; -#endif -#endif + // set up our RAM buffer size for program and user input + // NOTE: This number will have to change if you include other libraries. + // It is also an estimation. Might require adjustments... + #ifdef ENABLE_FILEIO + #define kRamFileIO (1030) /* approximate */ + #else + #define kRamFileIO (0) + #endif -#ifdef ENABLE_FILEIO -// functions defined elsehwere -void cmd_Files( void ); -#endif + #ifdef ENABLE_TONES + #define kRamTones (40) + #else + #define kRamTones (0) + #endif -//////////////////// + #define kRamSize (RAMEND - 1160 - kRamFileIO - kRamTones) +#endif /* ARDUINO Specifics */ -#ifdef ALIGN_MEMORY -// Align memory addess x to an even page -#define ALIGN_UP(x) ((unsigned char*)(((unsigned int)(x + 1) >> 1) << 1)) -#define ALIGN_DOWN(x) ((unsigned char*)(((unsigned int)x >> 1) << 1)) +// set up file includes for things we need, or desktop specific stuff. +#ifdef ARDUINO + // Use pgmspace/PROGMEM directive to store strings in progmem to save RAM + #include #else + #include + #include + #undef ENABLE_TONES + + // size of our program ram + #define kRamSize 64*1024 /* arbitrary - not dependant on libraries */ + + #ifdef ENABLE_FILEIO + FILE * fp; + #endif +#endif -#define ALIGN_UP(x) x -#define ALIGN_DOWN(x) x +//////////////////// +// memory alignment +// necessary for some esp8266-based devices +#ifdef ALIGN_MEMORY + // Align memory addess x to an even page + #define ALIGN_UP(x) ((unsigned char*)(((unsigned int)(x + 1) >> 1) << 1)) + #define ALIGN_DOWN(x) ((unsigned char*)(((unsigned int)x >> 1) << 1)) +#else + #define ALIGN_UP(x) x + #define ALIGN_DOWN(x) x #endif //////////////////// +// various other desktop-tweaks and such. #ifndef boolean -#define boolean int -#define true 1 -#define false 0 -#endif + #define boolean int + #define true 1 + #define false 0 #endif #ifndef byte -typedef unsigned char byte; + typedef unsigned char byte; #endif // some catches for AVR based text string stuff... #ifndef PROGMEM -#define PROGMEM + #define PROGMEM #endif #ifndef pgm_read_byte -#define pgm_read_byte( A ) *(A) + #define pgm_read_byte( A ) *(A) #endif //////////////////// #ifdef ENABLE_FILEIO -unsigned char * filenameWord(void); -static boolean sd_is_initialized = false; + // functions defined elsehwere + void cmd_Files( void ); + unsigned char * filenameWord(void); + static boolean sd_is_initialized = false; #endif +// some settings based things + boolean inhibitOutput = false; static boolean runAfterLoad = false; static boolean triggerRun = false; diff --git a/cli/GNUmakefile b/cli/GNUmakefile index 3d2bfca..fd97303 100644 --- a/cli/GNUmakefile +++ b/cli/GNUmakefile @@ -53,9 +53,9 @@ $(PROG): TinyBasicPlus.o main.o @$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@ -TinyBasicPlus.cpp: ../Arduino/TinyBasicPlus.ino - @echo copy $< to $@ - @cp $< $@ +TinyBasicPlus.cpp: ../TinyBasicPlus/TinyBasicPlus.ino + @echo Linking .cpp file to the Arduino .ino source + @ln -s $< $@ %.o: %.cpp @echo compile $< diff --git a/cli/desktop.h b/cli/desktop.h index f50b1f6..009eb21 100644 --- a/cli/desktop.h +++ b/cli/desktop.h @@ -7,5 +7,5 @@ #define false 0 #endif -#define kRamSize ( 64 * 1024 ) +//#define kRamSize ( 64 * 1024 )