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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))

CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
CFLAGS := -std=c99

$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)
Expand All @@ -19,7 +20,7 @@ clean:

-include $(DEPS)

# On the Linux command line:
# On the Linux or Mac OS command line:
# make creates tiff and leaves a bunch of object files in /src
# make clean deletes the object files as well as tiff

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ relying on C libraries for middleware and other wheels that you don't want to re
It's set up to compile to flash memory. Code space is flash (big) so that data space can be small.

Try `bin/tiff.exe` to play, if you like to live dangerously.
If you're a Linux user, compile from source using the Makefile.
If you're a Linux or Mac OS user, compile from source using the Makefile.
On Windows, I just pull all files in `src` into a Code::Blocks console project.

Windows users would do well to run this console app under Conemu.
Expand Down
6 changes: 3 additions & 3 deletions examples/ANS/vmConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
vmKeyFormat = 0 for Windows, 1 for Linux. The escape sequences are different.
*/

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
Expand All @@ -22,7 +22,7 @@
#include <conio.h>
#endif // __linux__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
// Linux uses cooked mode to input a command line (see Tiff.c's QUIT loop).
// Any keyboard input uses raw mode.
// Apparently, Windows getch does this switchover for us.
Expand Down Expand Up @@ -100,7 +100,7 @@ uint32_t vmKeyFormat(uint32_t dummy) {

uint32_t vmEmit(uint32_t c) {
putchar(c);
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
fflush(stdout);
usleep(1000);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/ANS/vmConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef __VMCONSOLE_H__
#define __VMCONSOLE_H__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
void CookedMode();
void RawMode();
#endif // __linux__
Expand Down
6 changes: 3 additions & 3 deletions examples/helloworld/vmConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
vmKeyFormat = 0 for Windows, 1 for Linux. The escape sequences are different.
*/

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
Expand All @@ -22,7 +22,7 @@
#include <conio.h>
#endif // __linux__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
// Linux uses cooked mode to input a command line (see Tiff.c's QUIT loop).
// Any keyboard input uses raw mode.
// Apparently, Windows getch does this switchover for us.
Expand Down Expand Up @@ -100,7 +100,7 @@ uint32_t vmKeyFormat(uint32_t dummy) {

uint32_t vmEmit(uint32_t c) {
putchar(c);
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
fflush(stdout);
usleep(1000);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/vmConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef __VMCONSOLE_H__
#define __VMCONSOLE_H__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
void CookedMode();
void RawMode();
#endif // __linux__
Expand Down
6 changes: 3 additions & 3 deletions examples/testbench/vmConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
vmKeyFormat = 0 for Windows, 1 for Linux. The escape sequences are different.
*/

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
Expand All @@ -22,7 +22,7 @@
#include <conio.h>
#endif // __linux__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
// Linux uses cooked mode to input a command line (see Tiff.c's QUIT loop).
// Any keyboard input uses raw mode.
// Apparently, Windows getch does this switchover for us.
Expand Down Expand Up @@ -125,7 +125,7 @@ uint32_t vmEmit(uint32_t xchar) {
}
char *s = c; char b;
while ((b = *s++)) putchar(b);
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
fflush(stdout);
usleep(1000);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/testbench/vmConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef __VMCONSOLE_H__
#define __VMCONSOLE_H__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
void CookedMode();
void RawMode();
#endif // __linux__
Expand Down
2 changes: 1 addition & 1 deletion src/accessvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <string.h>
#include <ctype.h>

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
#include <sys/ioctl.h>
#include <unistd.h>

Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "accessvm.h"
#include "fileio.h"
#include <string.h>
#include "vmhost.h"
#include "vmHost.h"
#define HP0max (MaxROMsize - 0x1000)

/*global*/ int HeadPointerOrigin = (ROMsizeDefault + RAMsizeDefault)*4;
Expand Down
2 changes: 1 addition & 1 deletion src/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This brings also Forth-like scripting and interactivity to C applications.

## Host Forth

The Host Forth is implemented in generic C. I use Code::Blocks to compile for Windows and execute it in ConEmu for decent VT220 emulation. I also compile and test it under Ubuntu Linux. Tiff is the name of the console application.
The Host Forth is implemented in generic C. I use Code::Blocks to compile for Windows and execute it in ConEmu for decent VT220 emulation. I also compile and test it under Ubuntu Linux. It is also supposed to work with Mac OS. Tiff is the name of the console application.

It implements an interpreter and a number of words using C. They use data structures in the Forth VM whenever possible. This tends to be more wordy than simply using C data structures, but it allows C functions to be replaced by Forth versions as they become available. For example, when the C version of the interpreter fills the TIB with text using C's `getline`, the Forth system running in the VM sees that same text in its TIB.

Expand Down
2 changes: 1 addition & 1 deletion src/rs232.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "rs232.h"


#if defined(__linux__) || defined(__FreeBSD__) /* Linux & FreeBSD */
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) /* Linux & FreeBSD & MacOS */

#define RS232_PORTNR 38

Expand Down
18 changes: 17 additions & 1 deletion src/rs232.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern "C" {



#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)

#include <termios.h>
#include <sys/ioctl.h>
Expand All @@ -60,6 +60,22 @@ extern "C" {

#endif

#if defined(__APPLE__)

#define B460800 460800
#define B500000 500000;
#define B576000 576000;
#define B921600 921600;
#define B1000000 1000000;
#define B1152000 1152000;
#define B1500000 1500000;
#define B2000000 2000000;
#define B2500000 2500000;
#define B3000000 3000000;
#define B3500000 3500000;
#define B4000000 4000000;
#endif

int RS232_OpenComport(int, int, const char *, int);
int RS232_PollComport(int, unsigned char *, int);
int RS232_SendByte(int, unsigned char);
Expand Down
6 changes: 3 additions & 3 deletions src/vmConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
vmKeyFormat = 0 for Windows, 1 for Linux. The escape sequences are different.
*/

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
Expand All @@ -22,7 +22,7 @@
#include <conio.h>
#endif // __linux__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
// Linux uses cooked mode to input a command line (see Tiff.c's QUIT loop).
// Any keyboard input uses raw mode.
// Apparently, Windows getch does this switchover for us.
Expand Down Expand Up @@ -100,7 +100,7 @@ uint32_t vmKeyFormat(uint32_t dummy) {

uint32_t vmEmit(uint32_t c) {
putchar(c);
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
fflush(stdout);
usleep(1000);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/vmConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef __VMCONSOLE_H__
#define __VMCONSOLE_H__

#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
void CookedMode();
void RawMode();
#endif // __linux__
Expand Down
Loading