Skip to content

Commit 5e22053

Browse files
committed
Updated to latest release of 7800basic
1 parent 8a79991 commit 5e22053

File tree

98 files changed

+11759
-9656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+11759
-9656
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ batari Basic created by Fred 'batari' Quimby is a BASIC-like language used in th
130130

131131
batari Basic is an external project is kindly currently maintained by Mike Saarna (RevEng) and can be downloaded separately [here](https://github.com/batari-Basic/batari-Basic). Further information is about this release is available here at [AtariAge](https://atariage.com/forums/topic/300856-official-home-for-batari-basic).
132132

133-
### 7800basic (release 0.24 - 20230302)
133+
### 7800basic (release 0.27 - 20230702)
134134
7800basic is a BASIC-like language for creating Atari 7800 games. It is a compiled language that runs on a computer, and it creates a binary file that can be run with an Atari 7800 emulator, or the binary file may be used to make a cartridge that will operate on a real Atari 7800. 7800basic is derived from batari basic, a BASIC-like language for creating Atari 2600 games. Special thanks to the bB creator, Fred Quimby, and all of the the bB contributors!
135135

136136
7800basic is included as part of this extension with many thanks to Mike Saarna (RevEng). 7800basic is an external project and can be downloaded separately [here](https://github.com/7800-devtools/7800basic). Further information about this release is available here at [AtariAge](http://atariage.com/forums/topic/222638-7800basic-beta-the-release-thread).

out/bin/compilers/7800basic/7800bas.c

Lines changed: 93 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ char stdoutfilename[256];
1212
FILE *stdoutfilepointer;
1313

1414
extern int currentdmahole;
15-
16-
#define BASIC_VERSION_INFO "7800basic v0.24"
17-
18-
int main(int argc, char *argv[])
15+
extern int numredefvars;
16+
extern int numconstants;
17+
extern char incbasepath[500];
18+
extern char redefined_variables[80000][100];
19+
extern char bannerfilenames[1000][100];
20+
extern char palettefilenames[1000][100];
21+
extern char currentcharset[256];
22+
extern int graphicsdatawidth[16];
23+
extern char charactersetchars[257];
24+
25+
#define BASIC_VERSION_INFO "7800basic v0.27"
26+
27+
int main (int argc, char *argv[])
1928
{
2029
char **statement;
2130
char **deallocate_mem;
@@ -39,7 +48,7 @@ int main(int argc, char *argv[])
3948
int defi = 0;
4049
path = NULL;
4150
// get command line arguments
42-
while ((i = getopt(argc, argv, "i:r:v")) != -1)
51+
while ((i = getopt (argc, argv, "i:r:v")) != -1)
4352
{
4453
switch (i)
4554
{
@@ -50,113 +59,70 @@ int main(int argc, char *argv[])
5059
filename = optarg;
5160
break;
5261
case 'v':
53-
printf("%s (%s, %s)\n", BASIC_VERSION_INFO, __TIME__, __DATE__);
54-
exit(0);
62+
printf ("%s (%s, %s)\n", BASIC_VERSION_INFO, __TIME__, __DATE__);
63+
exit (0);
5564
case '?':
56-
fprintf(stderr, "usage: %s -r <variable redefs file> -i <includes path>\n", argv[0]);
57-
exit(1);
65+
fprintf (stderr, "usage: %s -r <variable redefs file> -i <includes path>\n", argv[0]);
66+
exit (1);
5867
}
5968
}
6069

6170
// global variable init...
62-
condpart = 0;
63-
ongosub = 0;
64-
decimal = 0;
65-
romsize = 0;
66-
romat4k = 0;
67-
bankcount = 0;
68-
currentbank = 0;
69-
doublebufferused = 0;
70-
boxcollisionused = 0;
71-
dmaplain = 0;
72-
templabel = 0;
73-
doublewide = 0;
74-
zoneheight = 16;
75-
zonelocking = 0;
76-
superchip = 0;
77-
optimization = 0;
78-
smartbranching = 1;
79-
collisionwrap = 1;
80-
strcpy(redefined_variables[numredefvars++], "collisionwrap = 1");
81-
line = 0;
82-
numfixpoint44 = 0;
83-
numfixpoint88 = 0;
71+
strcpy (redefined_variables[numredefvars++], "collisionwrap = 1");
8472
incbasepath[0] = 0;
85-
includesfile_already_done = 0;
86-
tallspritemode = 1;
87-
multtableindex = 0;
8873
bannerfilenames[0][0] = 0;
8974
palettefilenames[0][0] = 0;
9075
currentcharset[0] = 0;
91-
ors = 0;
92-
numjsrs = 0;
93-
numfors = 0;
94-
numthens = 0;
95-
numelses = 0;
96-
numredefvars = 0;
97-
numconstants = 0;
98-
branchtargetnumber = 0;
99-
doingfunction = 0;
100-
sprite_index = 0;
101-
multisprite = 0;
102-
lifekernel = 0;
103-
playfield_number = 0;
104-
playfield_index[0] = 0;
105-
extra = 0;
106-
extralabel = 0;
107-
extraactive = 0;
108-
macroactive = 0;
10976

11077
for (i = 0; i < 16; i++)
11178
graphicsdatawidth[i] = 0;
11279

113-
strcpy(charactersetchars, " abcdefghijklmnopqrstuvwxyz.!?,\"$():");
80+
strcpy (charactersetchars, " abcdefghijklmnopqrstuvwxyz.!?,\"$():");
11481

115-
fprintf(stderr, "%s %s %s\n", BASIC_VERSION_INFO, __DATE__, __TIME__);
82+
fprintf (stderr, "%s %s %s\n", BASIC_VERSION_INFO, __DATE__, __TIME__);
11683

11784
// redirect STDOUT to 7800.asm, overwriting if it exists...
118-
strcpy(stdoutfilename, "7800.asm");
119-
if ((stdoutfilepointer = freopen(stdoutfilename, "w", stdout)) == NULL)
85+
strcpy (stdoutfilename, "7800.asm");
86+
if ((stdoutfilepointer = freopen (stdoutfilename, "w", stdout)) == NULL)
12087
{
121-
prerror("couldn't create the 7800.asm file.");
88+
prerror ("couldn't create the 7800.asm file.");
12289
}
12390

124-
printf(" ;%s %s %s\n", BASIC_VERSION_INFO, __DATE__, __TIME__);
91+
printf (" ;%s %s %s\n", BASIC_VERSION_INFO, __DATE__, __TIME__);
12592

126-
printf("SPACEOVERFLOW SET 0\n");
93+
printf ("SPACEOVERFLOW SET 0\n");
12794

12895
// these asm files are produced dynamically, so as to allow out-of-order
12996
// assembly with dasm. Their mere presence will affect the compile process
13097
// so we start off by wiping them, if they exist from a previous compile.
131-
remove("7800hole.0.asm");
132-
remove("7800hole.1.asm");
133-
remove("7800hole.2.asm");
134-
remove("banksetrom.asm");
135-
remove("banksetstrings.asm");
98+
remove ("7800hole.0.asm");
99+
remove ("7800hole.1.asm");
100+
remove ("7800hole.2.asm");
101+
remove ("banksetrom.asm");
102+
remove ("banksetstrings.asm");
136103

137104
char removefile[256];
138105
int t;
139-
for(t=0;t<100;t++)
106+
for (t = 0; t < 100; t++)
140107
{
141-
sprintf(removefile,"dump_gfx_%02d.bin",t);
142-
if(remove(removefile))
143-
break;
144-
sprintf(removefile,"dump_gfx_%02d.asm",t);
145-
remove(removefile);
108+
sprintf (removefile, "dump_gfx_%02d.bin", t);
109+
if (remove (removefile))
110+
break;
111+
sprintf (removefile, "dump_gfx_%02d.asm", t);
112+
remove (removefile);
146113
}
147-
148114

149-
create_a78info(); //wipe/create a78 parameter file
150115

151-
printf("game\n"); // label for start of game
152-
header_open(header);
153-
init_includes(path);
116+
create_a78info (); //wipe/create a78 parameter file
117+
118+
printf ("game\n"); // label for start of game
119+
init_includes (path);
154120

155-
statement = (char **) malloc(sizeof(char *) * 200);
121+
statement = (char **) malloc (sizeof (char *) * 200);
156122
deallocate_mem = statement;
157123
for (i = 0; i < 200; ++i)
158124
{
159-
statement[i] = (char *) malloc(sizeof(char) * 200);
125+
statement[i] = (char *) malloc (sizeof (char) * 200);
160126
}
161127

162128
while (1)
@@ -168,12 +134,12 @@ int main(int argc, char *argv[])
168134
statement[i][j] = '\0';
169135
}
170136
}
171-
c = fgets(code, 500, stdin); // get next line from input
172-
incline();
173-
strcpy(displaycode, code);
137+
c = fgets (code, 500, stdin); // get next line from input
138+
incline ();
139+
strcpy (displaycode, code);
174140

175141
// look for defines and remember them
176-
strcpy(mycode, code);
142+
strcpy (mycode, code);
177143
for (i = 0; i < 495; ++i)
178144
if (code[i] == ' ')
179145
break;
@@ -193,8 +159,8 @@ int main(int argc, char *argv[])
193159
defr[defi][j++] = code[i]; // get the definition
194160
}
195161
defr[defi][j] = '\0';
196-
removeCR(defr[defi]);
197-
printf(";.%s.%s.\n", def[defi], defr[defi]);
162+
removeCR (defr[defi]);
163+
printf (";.%s.%s.\n", def[defi], defr[defi]);
198164
defi++;
199165
}
200166
else if (defi)
@@ -208,24 +174,25 @@ int main(int argc, char *argv[])
208174
{
209175
if (defcount++ > 250)
210176
{
211-
fprintf(stderr, "(%d) Infinitely repeating definition or too many instances of a definition\n",
212-
bbgetline());
213-
exit(1);
177+
fprintf (stderr,
178+
"(%d) Infinitely repeating definition or too many instances of a definition\n",
179+
bbgetline ());
180+
exit (1);
214181
}
215-
codeadd = strstr(mycode, def[i]);
182+
codeadd = strstr (mycode, def[i]);
216183
if (codeadd == NULL)
217184
break;
218185
for (j = 0; j < 500; ++j)
219186
finalcode[j] = '\0';
220-
strncpy(finalcode, mycode, strlen(mycode) - strlen(codeadd));
221-
strcat(finalcode, defr[i]);
222-
strcat(finalcode, codeadd + strlen(def[i]));
223-
strcpy(mycode, finalcode);
187+
strncpy (finalcode, mycode, strlen (mycode) - strlen (codeadd));
188+
strcat (finalcode, defr[i]);
189+
strcat (finalcode, codeadd + strlen (def[i]));
190+
strcpy (mycode, finalcode);
224191
}
225192
}
226193
}
227-
if (strcmp(mycode, code))
228-
strcpy(code, mycode);
194+
if (strcmp (mycode, code))
195+
strcpy (code, mycode);
229196
if (!c)
230197
break; //end of file
231198

@@ -251,63 +218,63 @@ int main(int argc, char *argv[])
251218
else
252219
{
253220
multiplespace = 0;
254-
if (k < 199) //REVENG - avoid overrun when users use REM with long horizontal separators
221+
if (k < 199) // avoid overrun when users use REM with long horizontal separators
255222
statement[j][k++] = single;
256223
}
257224

258225
}
259226
if (j > 150)
260227
{
261-
fprintf(stderr, "(%d) Warning: long line\n", bbgetline());
228+
fprintf (stderr, "(%d) Warning: long line\n", bbgetline ());
262229
}
263230
if (statement[0][0] == '\0')
264231
{
265-
sprintf(statement[0], "L0%d", unnamed++);
232+
sprintf (statement[0], "L0%d", unnamed++);
266233
}
267-
if (strncmp(statement[0], "end\0", 3))
268-
printf(".%s ;; %s\n", statement[0], displaycode); // printf(".%s ; %s\n",statement[0],code);
234+
if (strncmp (statement[0], "end\0", 3))
235+
printf (".%s ;; %s\n", statement[0], displaycode); // printf(".%s ; %s\n",statement[0],code);
269236
else
270-
doend();
271-
272-
keywords(statement);
273-
if(numconstants==(MAXCONSTANTS-1))
274-
{
275-
fprintf(stderr, "(%d) Maximum number of constants exceeded.\n", bbgetline());
276-
exit(1);
277-
}
237+
doend ();
238+
239+
keywords (statement);
240+
if (numconstants == (MAXCONSTANTS - 1))
241+
{
242+
fprintf (stderr, "(%d) Maximum number of constants exceeded.\n", bbgetline ());
243+
exit (1);
244+
}
278245
}
279246

280-
printf("DMAHOLEEND%d SET .\n",currentdmahole);
247+
printf ("DMAHOLEEND%d SET .\n", currentdmahole);
281248

282249
//if stdout is redirected, change it back to 7800.asm so the gameend label goes in the right spot...
283-
if (strcmp(stdoutfilename, "7800.asm") != 0)
250+
if (strcmp (stdoutfilename, "7800.asm") != 0)
284251
{
285-
strcpy(stdoutfilename, "7800.asm");
286-
if ((stdoutfilepointer = freopen(stdoutfilename, "a", stdout)) == NULL)
252+
strcpy (stdoutfilename, "7800.asm");
253+
if ((stdoutfilepointer = freopen (stdoutfilename, "a", stdout)) == NULL)
287254
{
288-
prerror("couldn't reopen the 7800.asm file.");
255+
prerror ("couldn't reopen the 7800.asm file.");
289256
}
290257
}
291258

292-
printf("gameend\n");
259+
printf ("gameend\n");
293260

294-
barf_graphic_file();
261+
barf_graphic_file ();
295262

296-
barfmultiplicationtables();
263+
barfmultiplicationtables ();
297264

298-
printf(" if SPACEOVERFLOW > 0\n");
299-
printf(" echo \"\"\n");
300-
printf(" echo \"######## ERROR: space overflow detected in\",[SPACEOVERFLOW]d,\"areas.\"\n");
301-
printf(" echo \"######## look above for areas with negative ROM space left.\"\n");
302-
printf(" echo \"######## Aborting assembly.\"\n");
303-
printf(" ERR\n");
304-
printf(" endif\n");
265+
printf (" if SPACEOVERFLOW > 0\n");
266+
printf (" echo \"\"\n");
267+
printf (" echo \"######## ERROR: space overflow detected in\",[SPACEOVERFLOW]d,\"areas.\"\n");
268+
printf (" echo \"######## look above for areas with negative ROM space left.\"\n");
269+
printf (" echo \"######## Aborting assembly.\"\n");
270+
printf (" ERR\n");
271+
printf (" endif\n");
305272

306-
printf(" \n\n");
273+
printf (" \n\n");
307274

308-
header_write(header, filename);
309-
create_includes(includes_file);
310-
fprintf(stderr, "7800basic compilation complete.\n");
311-
freemem(deallocate_mem);
275+
header_write (header, filename);
276+
create_includes (includes_file);
277+
fprintf (stderr, "7800basic compilation complete.\n");
278+
freemem (deallocate_mem);
312279
return 0;
313280
}
Binary file not shown.
-4.13 KB
Binary file not shown.
-288 Bytes
Binary file not shown.
11.2 KB
Binary file not shown.
-4.76 KB
Binary file not shown.
Binary file not shown.
29.7 KB
Binary file not shown.
-744 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)