Edited by batari, Sat Jul 16, 2005 2:16 PM.
Atari 2600 BASIC compiler is here!
Started by batari, Jul 7 2005 4:10 AM
427 replies to this topic
#251
Posted Sat Jul 16, 2005 2:06 PM
I've posted new source with a fixed makefile that should compile in Linux, and I think Solaris requires the changes I made too - just spaced that some compilers require you to link in the math library which is where pow() lives.
#252
Posted Sat Jul 16, 2005 4:15 PM
batari, on Sat Jul 16, 2005 4:06 PM, said:
Fred, I had to make a few minor fixes for Mac OS X - spaces instead of tabs, or the other way around, I can't recall.
Re whitespace -- another annoying thing, if you have vertical whitespace, the line can't have spaces. My editor of choice (BBEdit, until my own IDE is ready!) adds blank lines already indented with whitespace to match the above line.
Thanks for the tip on array index, I figured out the workaround myself and I've got my game working mostly! (Uses almost all of your new language features... why thanks!) One new thing I've run into:
.L025; if x=2 goto moveworm LDA x CMP #2 Bus error
It doesn't matter what variable is on that line or what it's compared to. Pretty weird!
#253
Posted Sat Jul 16, 2005 4:28 PM
bliprob, on Sat Jul 16, 2005 5:15 PM, said:
batari, on Sat Jul 16, 2005 4:06 PM, said:
Fred, I had to make a few minor fixes for Mac OS X - spaces instead of tabs, or the other way around, I can't recall.
Re whitespace -- another annoying thing, if you have vertical whitespace, the line can't have spaces. My editor of choice (BBEdit, until my own IDE is ready!) adds blank lines already indented with whitespace to match the above line.
Thanks for the tip on array index, I figured out the workaround myself and I've got my game working mostly! (Uses almost all of your new language features... why thanks!) One new thing I've run into:
.L025; if x=2 goto moveworm LDA x CMP #2 Bus error
It doesn't matter what variable is on that line or what it's compared to. Pretty weird!
Regarding your error, you should try if x=2 then moveworm... goto won't be recognized in place of then right now and apparently really bad things will happen if you don't put a then somewhere. Another thing to add to the list - bus errors are never good.
Also, clearly the way I chose to skip blank lines wasn't good... The todo list is stacking up already.
#254
Posted Sat Jul 16, 2005 4:45 PM
bliprob, on Fri Jul 15, 2005 3:19 PM, said:
batari, on Fri Jul 15, 2005 6:11 PM, said:
Dan Iacovelli, on Fri Jul 15, 2005 3:35 PM, said:
I think the playfield commands are clear enough for instance: if you do pfhline 1 10 30 you will get a line on the bottom starting in the 1st column 10th row and 30 copies.
a more simple comparison is if you compre it to TI basic Playfield commands:
Call hchar ( row,column , char, rep) just have to reverse the row and column and
drop the char since batari basic doesn't use it.
a more simple comparison is if you compre it to TI basic Playfield commands:
Call hchar ( row,column , char, rep) just have to reverse the row and column and
drop the char since batari basic doesn't use it.
danwinslow, on Fri Jul 15, 2005 4:23 PM, said:
Batari, the parsing issues are going to drive you insane. I am speaking from personal experience. My advice is to set up a real parser now before you get too much kluged in there. It just gets worse as you go along. You need expression trees, BNF, etc. Yah, lex and yacc are good. Cryptic but they work.
Like, I'd rather have something that lets me say
IF x BETWEEN 0 AND z THEN INC X;
then
IF (X > 0) AND ((X < Z) OR P > 2) THEN X = X + 1
the latter implies full rich parsing which will generate ASM *no one* will want to look at. the former implies very atari- and programmer- focused thinking.
If there's every a trade off, say, between a few more kernals that can allow some cool new gaming ideas to be done or some new built in functions to do sound or whatever, or full rich parsing that lets me right complex statements in a single line, further removing me from the ASM being written, I'd strongly vote for the former.
So if this general kind of view wins out, there's no reason parsing needs to get much tougher than it is now. Parsing gets tough when it allows infinite nesting, you can say:
a = b
a = b + 10
a = b + (c / 2)
a = b + (21 * c + d) / 2)
and things get defined recursively. I think Batari need only go to the second level,
variable = (variable) (operator) (variable or constant)
That's pretty easy to parse, and it's nice that it kind of forces people to think about what variables they might accidentally be using.
PS, off to update the website now!
PPS no idea why my quotes aren't showing up as quotes
Edited by kisrael, Sat Jul 16, 2005 4:46 PM.
#255
Posted Sat Jul 16, 2005 5:33 PM
Quote
I think you have one missing /quote.Oh, and I would like to agree in the complex if-thens to some degree, in that one boolean is probably enough, which is the way it is now. Though I think it wouldn't hurt to allow slightly more complicated assignments, but I may stop at parentheses - once you get this far, the compiler will have to start using internal registers/memory to store intermediate values, and the memory to do this is already scarce. I'd rather have the programmer figure out where to use intermediate variables.
Keeping it simple also makes is easier for me to program and maintain. But sticking with the original vision of batari basic, some things will actually make it harder on me...
... Namely, I want the generated asm to be easy to follow. Which brings up another issue - conditional compilation of individual modules. It would be easy to make one huge assembly file and selectively compile only portions of it by conditional compilation flags. However, doing so makes the asm hard to read, especially for a beginner. Therefore, although it's much harder for me to program, I'm leaning toward generation of a new, clean assembly file for every compile where only relevant portions (as kernels, routines) are inserted in a logical place.
#257
Posted Sat Jul 16, 2005 6:50 PM
I'll second the idea of keeping it simple and close to assembly. Forcing the programmer to think that way while keeping nasty details out of the picture is the way to go.
Will build Linux version later today and get back to testing / building game.
Will build Linux version later today and get back to testing / building game.
#258
Posted Sat Jul 16, 2005 6:59 PM
My advice about doing a real parser is not to allow for complex statements. Its to keep Batari from going crazy trying to allow for the 80 million different teeny little issues that will be cropping up dealing with things like spacing, tabs, and any combination of unlikely characters. Hand-jamming a parser as you go, even if the syntax is relatively simple, can be very painful towards the end of the development.
#259
Posted Sat Jul 16, 2005 7:09 PM
batari, on Sat Jul 16, 2005 7:10 PM, said:
Fixed data statements... easy fix. This is what I get for coding them in without any testing whatsoever
#260
Posted Sat Jul 16, 2005 8:36 PM
Batari,
Thanks for your awesome contribution. Accessible 2600 programming, it's just incredible.
Chuck
Thanks for your awesome contribution. Accessible 2600 programming, it's just incredible.
Chuck
#261
Posted Sat Jul 16, 2005 9:18 PM
Stupid double post.
Edited by Tork110, Sat Jul 16, 2005 9:20 PM.
#262
Posted Sat Jul 16, 2005 9:18 PM
I have a question about the kernal. Is it suppose to be for the NTSC standard? Because my sprites seems to stretch the way it would when my old attempts at Atari 2600 programming went terribly wrong, (i.e., I used too many clock cycles for a scanline and the emulator or DASM thinks that I was trying to program for PAL.)
I also can't get the colors to work for the sprites. The sprites insist on being the same color as the score.
Note: This program isn't finished. It's based on an idea I had when I was trying to make a 2600 program by just assembly. It was sort of a reversed Kaboom! and based on popular web characters.
I guess my concerns might be moot since the next basic thing is out, but I'm still curious if I made a mistake.
I also can't get the colors to work for the sprites. The sprites insist on being the same color as the score.
Note: This program isn't finished. It's based on an idea I had when I was trying to make a 2600 program by just assembly. It was sort of a reversed Kaboom! and based on popular web characters.
I guess my concerns might be moot since the next basic thing is out, but I'm still curious if I made a mistake.
Attached Files
Edited by Tork110, Sat Jul 16, 2005 9:34 PM.
#263
Posted Sat Jul 16, 2005 9:33 PM
batari, on Sat Jul 16, 2005 9:09 PM, said:
Fred, thanks, that was quick! Although that's the one new feature I'm not using.
A few more things I've learned through many code/compile/debug cycles:
- a label with no line content fails -- all my labels have a blank "rem" after them.
- the blank line with one space thing is a huge pain, but it's my own fault. BBEdit almost always adds this, so part of my coding cycle is to grep the \r \r to \r\r.
Also, here's a tip -- if you run your file through 2600bas directly with stdout to the console, you can see exactly what lines your compilation is barfing on.
So my game is almost really work. I'm out of variables... and I need one more temp var for a calculation. if I can find an unused byte somewhere, I'll finish it and post it.
Edited by bliprob, Sat Jul 16, 2005 9:33 PM.
#264
Posted Sat Jul 16, 2005 9:51 PM
Just realized something else. Sorry for the large number of posts.
It appears that, to detect a collision, I have to use the not operator. As in, if NOT a collision goto my collision code (as above).
This is pretty weird, and I'm chalking it to my inexperience, but in case it's some weird thing (i.e. I'm on a Mac, maybe it's endian-related?) I thought I'd mention it.
if !collision(player0,playfield) then gosub hitself
It appears that, to detect a collision, I have to use the not operator. As in, if NOT a collision goto my collision code (as above).
This is pretty weird, and I'm chalking it to my inexperience, but in case it's some weird thing (i.e. I'm on a Mac, maybe it's endian-related?) I thought I'd mention it.
#265
Posted Sat Jul 16, 2005 10:07 PM
bliprob, on Sat Jul 16, 2005 10:51 PM, said:
It appears that, to detect a collision, I have to use the not operator. As in, if NOT a collision goto my collision code (as above).
Whew... glad I'm not the only one. I was poring over the docs trying to figure out what I was doing wrong.
I'll have to try the NOT operator (didn't think to try that). In my case it is detecting the collision immediately and the 2 objects aren't even remotely close to each other.
#266
Posted Sat Jul 16, 2005 10:23 PM
Still have linux issues 
Everything compiled but for this (in statements.c)
[in function let]
if (statement[4][0]=='0')
printf(" AND #%d\n",255 ^ pow(2,bit));
Got this:
cc -O2 -o 2600bas 2600bas.c statements.c keywords.c
statements.c: In function `let':
statements.c:775: error: invalid operands to binary ^
Let me know how I can help.
changed "^" to "*" just to see if that was the only problem.
Wasn't.
Linux still does not like the use of pow (int)pow(....)
Everything compiled but for this (in statements.c)
[in function let]
if (statement[4][0]=='0')
printf(" AND #%d\n",255 ^ pow(2,bit));
Got this:
cc -O2 -o 2600bas 2600bas.c statements.c keywords.c
statements.c: In function `let':
statements.c:775: error: invalid operands to binary ^
Let me know how I can help.
changed "^" to "*" just to see if that was the only problem.
Wasn't.
Linux still does not like the use of pow (int)pow(....)
Edited by potatohead, Sat Jul 16, 2005 10:55 PM.
#267
Posted Sat Jul 16, 2005 11:14 PM
potatohead, on Sat Jul 16, 2005 11:23 PM, said:
Still have linux issues 
Everything compiled but for this (in statements.c)
[in function let]
if (statement[4][0]=='0')
printf(" AND #%d\n",255 ^ pow(2,bit));
Got this:
cc -O2 -o 2600bas 2600bas.c statements.c keywords.c
statements.c: In function `let':
statements.c:775: error: invalid operands to binary ^
Let me know how I can help.
changed "^" to "*" just to see if that was the only problem.
Wasn't.
Linux still does not like the use of pow (int)pow(....)
Everything compiled but for this (in statements.c)
[in function let]
if (statement[4][0]=='0')
printf(" AND #%d\n",255 ^ pow(2,bit));
Got this:
cc -O2 -o 2600bas 2600bas.c statements.c keywords.c
statements.c: In function `let':
statements.c:775: error: invalid operands to binary ^
Let me know how I can help.
changed "^" to "*" just to see if that was the only problem.
Wasn't.
Linux still does not like the use of pow (int)pow(....)
In the meantime, I created a statically linked Linux binary - let me know if it works for you.
Attached Files
Edited by batari, Sat Jul 16, 2005 11:19 PM.
#268
Posted Sat Jul 16, 2005 11:25 PM
bliprob, on Sat Jul 16, 2005 10:51 PM, said:
Just realized something else. Sorry for the large number of posts.
It appears that, to detect a collision, I have to use the not operator. As in, if NOT a collision goto my collision code (as above).
This is pretty weird, and I'm chalking it to my inexperience, but in case it's some weird thing (i.e. I'm on a Mac, maybe it's endian-related?) I thought I'd mention it.
if !collision(player0,playfield) then gosub hitself
It appears that, to detect a collision, I have to use the not operator. As in, if NOT a collision goto my collision code (as above).
This is pretty weird, and I'm chalking it to my inexperience, but in case it's some weird thing (i.e. I'm on a Mac, maybe it's endian-related?) I thought I'd mention it.
In any case, do whatever works for you right now, just be aware that if it's a bug and it's fixed, your program might need to be updated before it will work under a new release.
#269
Posted Sat Jul 16, 2005 11:38 PM
batari, on Sun Jul 17, 2005 12:14 AM, said:
potatohead, on Sat Jul 16, 2005 11:23 PM, said:
Still have linux issues 
Everything compiled but for this (in statements.c)
[in function let]
if (statement[4][0]=='0')
printf(" AND #%d\n",255 ^ pow(2,bit));
Got this:
cc -O2 -o 2600bas 2600bas.c statements.c keywords.c
statements.c: In function `let':
statements.c:775: error: invalid operands to binary ^
Let me know how I can help.
changed "^" to "*" just to see if that was the only problem.
Wasn't.
Linux still does not like the use of pow (int)pow(....)
Everything compiled but for this (in statements.c)
[in function let]
if (statement[4][0]=='0')
printf(" AND #%d\n",255 ^ pow(2,bit));
Got this:
cc -O2 -o 2600bas 2600bas.c statements.c keywords.c
statements.c: In function `let':
statements.c:775: error: invalid operands to binary ^
Let me know how I can help.
changed "^" to "*" just to see if that was the only problem.
Wasn't.
Linux still does not like the use of pow (int)pow(....)
In the meantime, I created a statically linked Linux binary - let me know if it works for you.
I'll give it a try. I have it working now. (uh, the one I patched up with it's own pow2 function) Think I am having lf/cr trouble because I'm getting syntax errors in dasm. Sure enough <cr> is present in those lines. You posted how to fix that however, so I'll do that and do some testing...
I'm running Mandrake 10 smp
I came to a similar conclusion about pow. I went ahead and wrote a little powers of two function that appeared to work nicely.
added to statements.h
int pow2 (int);
added to statements.c
int pow2 (int n)
{
auto int t;
auto int x = 2;
if (n < 0)
{
n = -n;
}
while (n)
{
if (n & 1) t *= x;
n >>= 1;
x *= x;
}
return t;
}
also in statements.c where pow appears, the following was substitued:
pow2 (xx);
Edited by potatohead, Sat Jul 16, 2005 11:41 PM.
#270
Posted Sat Jul 16, 2005 11:46 PM
Tork110, on Sat Jul 16, 2005 10:18 PM, said:
I have a question about the kernal. Is it suppose to be for the NTSC standard? Because my sprites seems to stretch the way it would when my old attempts at Atari 2600 programming went terribly wrong, (i.e., I used too many clock cycles for a scanline and the emulator or DASM thinks that I was trying to program for PAL.)
Quote
I also can't get the colors to work for the sprites. The sprites insist on being the same color as the score.
Quote
Note: This program isn't finished. It's based on an idea I had when I was trying to make a 2600 program by just assembly. It was sort of a reversed Kaboom! and based on popular web characters.
I guess my concerns might be moot since the next basic thing is out, but I'm still curious if I made a mistake.
I guess my concerns might be moot since the next basic thing is out, but I'm still curious if I made a mistake.
#271
Posted Sun Jul 17, 2005 12:00 AM
Quote
Think I am having lf/cr trouble because I'm getting syntax errors in dasm. Sure enough <cr> is present in those lines. You posted how to fix that however, so I'll do that and do some testing...
The Alpha-ness of this is really starting to reveal itself.
Quote
I came to a similar conclusion about pow. I went ahead and wrote a little powers of two function that appeared to work nicely.
#272
Posted Sun Jul 17, 2005 12:41 AM
batari, on Sun Jul 17, 2005 1:00 AM, said:
Quote
Think I am having lf/cr trouble because I'm getting syntax errors in dasm. Sure enough <cr> is present in those lines. You posted how to fix that however, so I'll do that and do some testing...
The Alpha-ness of this is really starting to reveal itself.
Quote
I came to a similar conclusion about pow. I went ahead and wrote a little powers of two function that appeared to work nicely.
LOL
This really shows the wisdom of keeping the function set down to a minimum. The set of keywords for this alpha will open a lot of doors. Adding to the set, from now on, probably should be only for things not easily possible otherwise, IMHO.
Are the temp vars still a part of things?
#273
Posted Sun Jul 17, 2005 1:15 AM
potatohead, on Sun Jul 17, 2005 1:41 AM, said:
The usage of temp vars has not changed. However, I think I will need to use one more for the playfield routines when I change them to allow indexed variables in their arguments. I should keep a detailed record of variable usage in various routines and put it in the help file so people know when the temp vars are going to be obliterated.#274
Posted Sun Jul 17, 2005 1:21 AM
batari, on Sun Jul 17, 2005 1:00 AM, said:
Would have been a piece of cake to do with lex. You really should use lex/yacc or at least lex. Your grammar is probably simple enough to handcraft a parser without going mad. Personally I wouldn't have used C in the first place but Java and I'd written the scanner/parser stuff with JavaCC.
If you want I can help you autotoolize the code, so you don't have to worry that much about makefiles anymore.
#275
Posted Sun Jul 17, 2005 1:43 AM
Tom, on Sun Jul 17, 2005 2:21 AM, said:
Would have been a piece of cake to do with lex. You really should use lex/yacc or at least lex. Your grammar is probably simple enough to handcraft a parser without going mad.
Quote
That would be great! The more help I get, the better...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
















