Skip to content

Commit

Permalink
Release 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RodionGork committed Aug 8, 2018
1 parent 5763475 commit 70e99c2
Show file tree
Hide file tree
Showing 24 changed files with 4,777 additions and 208 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
**Miskatino Basic for Arduino Mini (with 2k RAM) v1.1**
# Miskatino Releases

Just open it in your Arduino IDE and upload to your chip.
### Miskatino Basic for Arduino

It could also be compiled for other Arduinos with sufficient RAM,
e.g. for Arduino Pro Micro / Leonardo.
It can be used with various chips having at least 2k of RAM:

- Arduino Pro Mini / Nano / Duemilanove (AtMega328)
- Arduino Pro Micro / Leonardo (AtMega32u4)

Just open the folder `arduino-src` in your Arduino IDE and upload to your chip.

It will work with default `Serial` connection (i.e. first UART on Mini or USB on Micro).

However you may want to change `Serial` in this case so that MCU
works with UART interface (D0-D1) instead of USB - this can be
helpful when attaching Bluetooth module, for example. Just
change `Serial` to `Serial1` in the `ardubasic.ino`.

Note that default baud rate is 115200. To work with BlueTooth modules it should
be either changed to 9600 or the module itself should be reconfigured to higher speed.

### Miskatino Basic for STM32F103

Upload the hex file to your controller. It will work via first UART. Default
baud rate is 115200.

Pins 0-15 are assigned to PA0-PA15. ADC pins are the same as digital pins 0-7.
929 changes: 929 additions & 0 deletions arduino-bin/bare-atmega328-8mhz.hex

Large diffs are not rendered by default.

1,085 changes: 1,085 additions & 0 deletions arduino-bin/micro-or-leonardo.hex

Large diffs are not rendered by default.

930 changes: 930 additions & 0 deletions arduino-bin/mini-nano-duemilanove-16mhz.hex

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions arduino-mini/main.h

This file was deleted.

24 changes: 15 additions & 9 deletions arduino-mini/ardubasic.ino → arduino-src/ardubasic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#include "mytypes.h"
#include "textual.h"
#include "tokens.h"
#include "extern.h"

#define UART_SPEED 115200

#define PROG_SPACE_SIZE 700
#define VARS_SPACE_SIZE 300
#define LINE_SIZE 40

char extraCmdArgCnt[] = {2, 2};

Expand All @@ -19,11 +21,12 @@ static const char commonStrings[] PROGMEM = CONST_COMMON_STRINGS;
static const char parsingErrors[] PROGMEM = CONST_PARSING_ERRORS;

char dataSpace[VARS_SPACE_SIZE + PROG_SPACE_SIZE];
char lineSpace[LINE_SIZE * 3];

short filePtr;

short sysGetc(void) {
return Serial.read();
char sysGetc(void) {
return (Serial.available() > 0) ? (char) Serial.read() : 0;
}

void sysPutc(char c) {
Expand Down Expand Up @@ -74,11 +77,11 @@ uchar peek(short addr) {
return *((uchar*) addr);
}

void sysQuit(void) {
}

void sysDelay(numeric pause) {
delay(pause);
numeric sysMillis(numeric div) {
if (div <= 1) {
(numeric) millis();
}
return (numeric) (millis() / div);
}

void outputConstStr(char strId, char index, char* w) {
Expand Down Expand Up @@ -186,10 +189,11 @@ char storageOperation(void* data, short size) {
return 1;
}
size = EEPROM.read(1);
size = ((size << 8) | EEPROM.read(0)) + 2;
size = ((size << 8) | EEPROM.read(0));
if (size <= 0 || size >= PROG_SPACE_SIZE) {
return 0;
}
size += 2;
return storageChecksum(size + 1) == 0;
}
}
Expand All @@ -208,10 +212,12 @@ char storageOperation(void* data, short size) {

void setup() {
Serial.begin(UART_SPEED);
init(dataSpace, VARS_SPACE_SIZE);
while (!Serial);
init(VARS_SPACE_SIZE, LINE_SIZE);
}

void loop() {
lastInput = sysGetc();
dispatch();
}

41 changes: 28 additions & 13 deletions arduino-mini/editor.cpp → arduino-src/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,40 @@
#include "tokens.h"
#include "extern.h"

extern token* toksBody;
char* prgStore;
short prgSize;
static char lineSpacePos;
char lastInput;

void resetEditor(void) {
((prgline*)prgStore)->num = 0;
prgSize = 2;
lineSpacePos = 0;
}

void initEditor(char* prgBody) {
prgStore = prgBody;
resetEditor();
}

char readLine(char* line) {
if (!input(line, MAX_LINE_LEN)) {
return 0;
char readLine() {
if (lastInput == '\r' || lastInput == '\n') {
trim(lineSpace);
lineSpace[lineSpacePos] = 0;
lineSpacePos = 0;
sysEcho('\n');
return 1;
} else if (lastInput == '\b' || lastInput == 127) {
if (lineSpacePos > 0) {
lastInput = '\b';
lineSpacePos -= 1;
}
} else if (lastInput >= ' ') {
lineSpace[lineSpacePos++] = lastInput;
}
trim(line);
return 1;
sysEcho(lastInput);
return 0;
}

short lineSize(prgline* p) {
Expand Down Expand Up @@ -79,27 +94,27 @@ char editorLoad(void) {
return 1;
}

char editorLoadParsed(char* lineBuf, token* tokenBuf) {
char editorLoadParsed() {
void* p = prgStore;
unsigned char len;
if (!storageOperation(NULL, -1)) {
return 0;
}
storageOperation(lineBuf, -2);
storageOperation(lineSpace, -2);
while (1) {
storageOperation(p, (short) -sizeof(short));
if (*((short*)p) == 0) {
break;
}
parseLine(lineBuf, tokenBuf);
parseLine(lineSpace, toksBody);
p = (char*)p + sizeof(short);
storageOperation(&len, (short) -sizeof(len));
storageOperation(lineBuf, -len);
lineBuf[len] = 0;
parseLine(lineBuf, tokenBuf);
len = tokenChainSize(tokenBuf);
storageOperation(lineSpace, -len);
lineSpace[len] = 0;
parseLine(lineSpace, toksBody);
len = tokenChainSize(toksBody);
*((char*)p) = len;
memcpy((char*)p + 1, tokenBuf, len);
memcpy((char*)p + 1, toksBody, len);
p = (char*)p + len + 1;
}
storageOperation(NULL, 0);
Expand Down
4 changes: 2 additions & 2 deletions arduino-mini/editor.h → arduino-src/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ extern short prgSize;

void resetEditor(void);
void initEditor(char* prgBody);
char readLine(char* line);
char readLine();
prgline* findLine(short num);
void injectLine(char* s, short num);
char editorSave(void);
char editorLoad(void);
char editorLoadParsed(char* lineBuf, token* tokenBuf);
char editorLoadParsed(void);

#endif

Loading

0 comments on commit 70e99c2

Please sign in to comment.