annotate harelet.c @ 21:44e906aeea91 default tip

Added Windows and DOS support
author VilyaemKenyaz
date Wed, 27 Sep 2023 09:28:49 -0400
parents 0555050bada0
children
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>
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
10 #include <assert.h>
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
11
20
0555050bada0 Make it pretty
VilyaemKenyaz
parents: 19
diff changeset
12 #include "based/basedfilelib.h"
0555050bada0 Make it pretty
VilyaemKenyaz
parents: 19
diff changeset
13 #include "based/basedtermgrx.h"
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
14
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
15 #define DEEPNESS 5
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
16 #define MAXPOINT 4096
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
17 #define UNITS "G20\n"
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
18 #define SPEED 20
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
19
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
20 typedef struct{
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
21 unsigned int X;
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
22 unsigned int Y;
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
23 unsigned int down;
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
24 }point;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
25
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
26 point points[MAXPOINT];
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
27
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
28 unsigned int X = 5;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
29 unsigned int Y = 5;
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
30 unsigned int step = 5;
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
31 unsigned int down = 0;
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
32 unsigned int numpoints = 0;
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
33 char action;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
34
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
35
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
36 /*********************************************
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
37 * Description - Warn the user about something
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
38 * Author - William King
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
39 * Date - Sep 27 2023
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
40 * *******************************************/
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
41 void Warn(char * s){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
42 printf("WARNING:");
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
43 puts(s);
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
44 putchar('\a');
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
45 getchar();
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
46 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
47
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
48 /*********************************************
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
49 * Description - Convert integers to strings, makes
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
50 * source code more pretty.
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
51 * Author - William King
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
52 * Date - Sep 26 2023
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
53 * *******************************************/
20
0555050bada0 Make it pretty
VilyaemKenyaz
parents: 19
diff changeset
54 char * IntToString(unsigned int num){
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
55 char * s;
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
56 sprintf(s,"%d",num);
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
57 return s;
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
58 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
59
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
60 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
61 * Description - Renders the screen
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
62 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
63 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
64 * *******************************************/
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
65 void Render(){
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
66 ClrScr();
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
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
71 if(numpoints > 0){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
72 for(int i = 0;i != numpoints;i++){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
73 if(points[i].down == 0){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
74 DrawChar(points[i].X,points[i].Y,'U');
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
75
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
76 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
77 else{
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
78 DrawChar(points[i].X,points[i].Y,'D');
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
79 }
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
80 }
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
81 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
82
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
83 //Render cursor
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
84 DrawChar(X,Y,'&');
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
85
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
86 Splash();
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
87
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
88 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
89
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
90 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
91 * Description - This function compiles instructions for CNC machines.
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
92 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
93 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
94 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
95 void Compile(){
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
96
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
97 char filename[64];
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
98 char file[8192];
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
99 char buffer[64];
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
100 unsigned int choice;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
101
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
102 puts("Select your format\n1. RAW GCODE\n2. OPENSBP");
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
103 scanf("%d",&choice);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
104
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
105
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
106 puts("Enter the filename");
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
107 scanf("%s",filename);
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
108 printf("Compiling %s...\n",filename);
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
109 if(choice == 1){
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
110 //Set the miller
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
111 strcat(file,UNITS);
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
112 strcat(file,"G0 X0 Y0 Z0\n");
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
113 //Meat of instructions
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
114 for(int i = 0;i != numpoints;i++){
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
115 //Compose
15
ef57eb9ec02b Automated Vimcurial commmit
VilyaemKenyaz
parents: 14
diff changeset
116 char instruction[64];
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
117 strcat(instruction,"G0 X ");
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
118 strcat(instruction,IntToString(points[i].X));
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
119 strcat(instruction," Y ");
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
120 strcat(instruction,IntToString(points[i].Y));
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
121 if(points[i].down == 1){
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
122 strcat(instruction," Z 5\n");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
123 }
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
124 else{
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
125 strcat(instruction," Z 0\n");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
126 }
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
127 //Write to string
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
128 strcat(file,instruction);
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
129 }
16
43dcb67b173d Automated Vimcurial commmit
VilyaemKenyaz
parents: 15
diff changeset
130
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
131 //Finish
13
8fe2392f2fcc Automated Vimcurial commmit
VilyaemKenyaz
parents: 12
diff changeset
132 strcat(file,"G0 X0 Y0 Z0\n");
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
133 WriteFile(filename,file);
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
134 }
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
135 else if(choice == 2){
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
136 // Setup the miller
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
137 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");
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
138
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
139 for(int i = 0;i != numpoints;i++){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
140
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
141 char instruction[64];
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
142
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
143 strcat(instruction,"J2 ");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
144 strcat(instruction,IntToString(points[i].X));
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
145 strcat(instruction," ");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
146 strcat(instruction,IntToString(points[i].Y));
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
147 strcat(instruction,"\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
148
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
149 if(points[i].down == 0){
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
150 strcat(instruction,"MZ -0,0625\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
151 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
152 else{
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
153 strcat(instruction,"JZ,&ZUP\n");
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
154 }
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
155
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
156 strcat(file,instruction);
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
157 }
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
158
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
159 //Finished, add instructions to wait for the user
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
160 strcat(file,"\nJ2,0,0\nSO, 1,0\n'All done. Wait for user.\nPAUSE");
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
161
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
162 WriteFile(filename,file);
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
163
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
164 }
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
165 else{
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
166 Warn("Invalid compiliation format");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
167 }
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
168
18
7bf25e90a1de Finished writing OpenSBP Shopbot compiler
VilyaemKenyaz
parents: 16
diff changeset
169 puts("Finished compiling instructions");
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
170 getchar();
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
171
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
172 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
173
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
174
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
175 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
176 * Description - Main function
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
177 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
178 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
179 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
180 void main(int argc, char* argv[]){
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
181 while(1){
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
182 Render();
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
183 #ifndef DVORAK
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
184 switch(getchar()){
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
185 case 'h':
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
186 if(X - step >= 2){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
187 X -= step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
188 }
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
189 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
190 case 'j':
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
191 if(Y + step < RESY - step){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
192 Y += step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
193 }
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
194 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
195 case 'k':
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
196 if(Y - step >= 2){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
197 Y -= step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
198 }
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
199 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
200 case 'l':
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
201 if(X + step < RESX - step){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
202 X += step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
203 }
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
204 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
205 case 's':
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
206 puts("New stepsize:");
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
207 scanf("%d",&step);
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
208 break;
9
4eb02dffc00f Automated Vimcurial commmit
VilyaemKenyaz
parents: 8
diff changeset
209
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
210 case 'a':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
211 points[numpoints].X = X;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
212 points[numpoints].Y = Y;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
213 points[numpoints].down = down;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
214 numpoints++;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
215 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
216 case 'd':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
217 if(down == 1){
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
218 down = 0;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
219 }
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
220 else{
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
221 down = 1;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
222 }
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
223 break;
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
224 case 'c':
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
225 Compile();
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
226 break;
14
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
227 case 'q':
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
228 ClrScr();
14
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
229 exit(0);
8b5ff478ec66 Automated Vimcurial commmit
VilyaemKenyaz
parents: 13
diff changeset
230 break;
12
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
231 default:
35e6a7b53e3c Automated Vimcurial commmit
VilyaemKenyaz
parents: 11
diff changeset
232 break;
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
233 }
19
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
234 #endif
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
235 #ifdef DVORAK
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
236 switch(getchar()){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
237 case 'a':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
238 if(X - step >= 2){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
239 X -= step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
240 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
241 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
242 case 'o':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
243 if(Y + step < RESY - step){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
244 Y += step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
245 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
246 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
247 case ',':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
248 if(Y - step >= 2){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
249 Y -= step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
250 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
251 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
252 case 'e':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
253 if(X + step < RESX - step){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
254 X += step;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
255 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
256 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
257 case '.':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
258 puts("New stepsize:");
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
259 scanf("%d",&step);
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
260 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
261
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
262 case ' ':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
263 points[numpoints].X = X;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
264 points[numpoints].Y = Y;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
265 points[numpoints].down = down;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
266 numpoints++;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
267 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
268 case 'p':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
269 if(down == 1){
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
270 down = 0;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
271 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
272 else{
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
273 down = 1;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
274 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
275 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
276 case 'y':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
277 Compile();
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
278 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
279 case 'q':
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
280 ClrScr();
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
281 exit(0);
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
282 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
283 default:
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
284 break;
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
285 }
8fe0b5711413 Added BasedTremGrx and Dvorak
VilyaemKenyaz
parents: 18
diff changeset
286 #endif
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
287 }
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
288
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
289 exit(0);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
290 }