annotate harelet.c @ 18:7bf25e90a1de

Finished writing OpenSBP Shopbot compiler
author VilyaemKenyaz
date Tue, 26 Sep 2023 23:19:42 -0400
parents 43dcb67b173d
children 8fe0b5711413
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
1 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
2 * Description - Harelet is a CAD and compiler program for CNC milling machines
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
3 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
4 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
5 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
6
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
7 #include <stdio.h>
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
8 #include <stdlib.h>
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
9 #include <string.h>
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
10
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
11 #include "basedfilelib.h"
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
12
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
13 #ifdef __linux__
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
14 #include "linuxconio.h"
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
15 #endif
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
16
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
17 #ifdef _WIN32
11
1d4df12de9e3 Automated Vimcurial commmit
VilyaemKenyaz
parents: 10
diff changeset
18 #include <windows.h>>
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
19 #include <conio.h>
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
20 #endif
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
21
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
22 #define DEEPNESS 5
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
23 #define MAXPOINT 4096
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
24 #define UNITS "G20\n"
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
25 #define SPEED 20
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
26
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
27 #define SBPUP "JZ &ZUP\n"
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
28 #define SBPDWN 0.0625
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
29
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
30
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
31 typedef struct{
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
32 unsigned int X;
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
33 unsigned int Y;
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
34 unsigned int down;
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
35 }point;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
36
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
37 point points[MAXPOINT];
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
38
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
39 unsigned int X = 100;
11
1d4df12de9e3 Automated Vimcurial commmit
VilyaemKenyaz
parents: 10
diff changeset
40 unsigned int Y = 25;
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
41 unsigned int step = 5;
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
42 unsigned int down = 0;
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
43 unsigned int numpoints = 0;
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
44 char action;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
45
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
46
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
47 /*********************************************
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
48 * Description - Convert integers to strings, makes
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
49 * source code more pretty.
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
50 * Author - William King
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
51 * Date - Sep 26 2023
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
52 * *******************************************/
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
53 char * IntToString(int num){
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
54 char * s;
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
55 sprintf(s,"%d",num);
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
56 return s;
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
57 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
58
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
59 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
60 * Description - Renders the screen
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
61 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
62 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
63 * *******************************************/
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
64 void Render(){
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
65 clrscr();
10
c73aed540bdd Automated Vimcurial commmit
VilyaemKenyaz
parents: 9
diff changeset
66 gotoxy(0,3);
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
67 puts("HARELET A CAD PROGRAM BY VILYAEM KENYAZ, PEEP SOFTWARE 2023");
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
68 printf("Number of Points: %d X: %d Y: %d STEPSIZE: %d DWN?: %d\n",numpoints,X,Y,step,down);
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
69
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
70 //Render points
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
71 for(int i = 0;i != MAXPOINT;i++){
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
72 gotoxy(0,50);
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
73
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
74 gotoxy(points[i].X,points[i].Y);
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
75
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
76 if(points[i].down == 0){
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
77 printf("X");
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
78 }
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
79 else{
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
80 printf("*");
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
81 }
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
82
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
83
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
84 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
85
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
86 //Render cursor
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
87
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
88 gotoxy(X,Y);
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
89
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
90 puts("&");
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
91
10
c73aed540bdd Automated Vimcurial commmit
VilyaemKenyaz
parents: 9
diff changeset
92 //Move cursor to top of document, so its not trailing the cadcursor
c73aed540bdd Automated Vimcurial commmit
VilyaemKenyaz
parents: 9
diff changeset
93 gotoxy(0,0);
c73aed540bdd Automated Vimcurial commmit
VilyaemKenyaz
parents: 9
diff changeset
94
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
95
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
96
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
97 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
98
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
99 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
100 * Description - This function compiles instructions for CNC machines.
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
101 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
102 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
103 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
104 void Compile(){
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
105
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
106 char filename[64];
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
107 char file[8192];
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
108 char buffer[64];
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
109 unsigned int choice;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
110
11
1d4df12de9e3 Automated Vimcurial commmit
VilyaemKenyaz
parents: 10
diff changeset
111 clrscr();
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
112 puts("Select your format\n1. RAW GCODE\n2. OPENSBP");
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
113 scanf("%d",&choice);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
114
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
115
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
116 puts("Enter the filename");
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
117 scanf("%s",filename);
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
118 printf("Compiling %s...\n",filename);
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
119 if(choice == 1){
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
120 //Set the miller
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
121 strcat(file,UNITS);
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
122 strcat(file,"G0 X0 Y0 Z0\n");
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
123 //Meat of instructions
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
124 for(int i = 0;i != numpoints;i++){
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
125 //Compose
15
ef57eb9ec02b Automated Vimcurial commmit
VilyaemKenyaz
parents: 14
diff changeset
126 char instruction[64];
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
127 strcat(instruction,"G0 X ");
14
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
128 //Convert X to string
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
129 sprintf(buffer,"%d",points[i].X);
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
130 strcat(instruction,buffer);
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
131 strcat(instruction," Y ");
11
1d4df12de9e3 Automated Vimcurial commmit
VilyaemKenyaz
parents: 10
diff changeset
132 //Convert Y to string
14
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
133 sprintf(buffer,"%d",points[i].Y);
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
134 strcat(instruction,buffer);
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
135 if(points[i].down = 1){
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
136 strcat(instruction," Z 5\n");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
137 }
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
138 else{
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
139 strcat(instruction," Z 0\n");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
140 }
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
141 //Write to string
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
142 strcat(file,instruction);
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
143 }
16
43dcb67b173d Automated Vimcurial commmit
VilyaemKenyaz
parents: 15
diff changeset
144
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
145 //Finish
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
146 strcat(file,"G0 X0 Y0 Z0\n");
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
147 WriteFile(filename,file);
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
148 }
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
149 else if(choice == 2){
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
150 // Setup the miller
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
151 strcat(file,"'OpenSBP file written by Harelet\n'Harelet, written by William King\n'No responsibilty is taken for any damages to any equipment\n\n'Starting\nSO, 1,1\nPause 2\nSA,\n&ZUP = 0.25\nMH\n\n'Bulk of instructions\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
152
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
153 for(int i = 0;i != numpoints;i++){
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
154
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
155 char instruction[64];
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
156
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
157 strcat(instruction,"J2 ");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
158 strcat(instruction,IntToString(points[i].X));
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
159 strcat(instruction," ");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
160 strcat(instruction,IntToString(points[i].Y));
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
161 strcat(instruction,"\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
162
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
163 if(points[i].down == 0){
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
164 strcat(instruction,"MZ -0,0625\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
165 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
166 else{
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
167 strcat(instruction,"JZ,&ZUP\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
168 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
169
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
170
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
171 strcat(file,instruction);
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
172 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
173
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
174 //Finished, add instructions to wait for the user
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
175 strcat(file,"\nJ2,0,0\nSO, 1,0\n'All done. Wait for user.\nPAUSE");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
176
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
177 WriteFile(filename,file);
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
178
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
179 }
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
180 else{
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
181
16
43dcb67b173d Automated Vimcurial commmit
VilyaemKenyaz
parents: 15
diff changeset
182 puts("Invalid compiliation format");
43dcb67b173d Automated Vimcurial commmit
VilyaemKenyaz
parents: 15
diff changeset
183 scanf("");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
184
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
185
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
186 }
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
187
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
188 puts("Finished compiling instructions");
16
43dcb67b173d Automated Vimcurial commmit
VilyaemKenyaz
parents: 15
diff changeset
189 scanf("");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
190
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
191 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
192
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
193
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
194 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
195 * Description - Main function
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
196 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
197 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
198 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
199 void main(int argc, char* argv[]){
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
200 clrscr();
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
201 while(1){
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
202 Render();
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
203 switch(getchar()){
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
204 case 'h':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
205 X -= step;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
206 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
207 case 'j':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
208 Y += step;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
209 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
210 case 'k':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
211 Y -= step;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
212 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
213 case 'l':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
214 X += step;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
215 break;
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
216
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
217 case 's':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
218 puts("New stepsize");
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
219 scanf("%d",&step);
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
220
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
221 break;
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
222
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
223 case 'a':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
224 points[numpoints].X = X;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
225 points[numpoints].Y = Y;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
226 points[numpoints].down = down;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
227 numpoints++;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
228 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
229 case 'd':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
230 if(down == 1){
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
231 down = 0;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
232 }
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
233 else{
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
234 down = 1;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
235 }
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
236 break;
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
237
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
238 case 'c':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
239 Compile();
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
240 break;
14
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
241 case 'q':
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
242 clrscr();
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
243 exit(0);
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
244 break;
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
245 default:
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
246 putchar('\a');
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
247 break;
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
248 }
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
249 }
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
250
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
251 exit(0);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
252 }