Go Back   Flash Flash Revolution > Gaming > Stepmania
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
Old 09-26-2007, 09:29 PM   #1
andrewshen123
FFR Player
 
Join Date: Jun 2005
Posts: 22
Send a message via MSN to andrewshen123
Default Parsing .sm files

Well, I'm trying to program an FFR clone so that I can upload my own files at will, and everything was going smoothly until I realized that I had no idea how to read the contents of .sm files (this took about 2 seconds, so there wasn't actually much "going smoothly"). Would any of the programmers here mind telling me, or giving me a page that would?
andrewshen123 is offline   Reply With Quote
Old 09-27-2007, 08:57 AM   #2
jyris1
FFR Player
 
jyris1's Avatar
 
Join Date: Oct 2006
Posts: 133
Default Re: Parsing .sm files

Are you trying to write it in Flash?
jyris1 is offline   Reply With Quote
Old 09-27-2007, 12:37 PM   #3
andrewshen123
FFR Player
 
Join Date: Jun 2005
Posts: 22
Send a message via MSN to andrewshen123
Default Re: Parsing .sm files

Well, yes, but that isn't really important right now. The .sm file doesnt change depending on what language you're using...
andrewshen123 is offline   Reply With Quote
Old 09-27-2007, 06:05 PM   #4
Yesssss
FFR Player
 
Yesssss's Avatar
 
Join Date: Jul 2005
Location: In a Lawnmower
Age: 35
Posts: 2,522
Send a message via AIM to Yesssss
Default Re: Parsing .sm files

I'm assuming you don't know how to read the arrows off of a *.sm file. Everything else is really obvious (except maybe stops, bpms, and difficulty types).

Here's a standard measure:
1000
0100
0010
0001
,
Since there is only 4 lines, the most complicated note in there is a 4th note. If I have 8 lines, each line would indicate an 8th, etc. This would be a 16th roll:
1000
0100
0010
0001
1000
0100
0010
0001
1000
0100
0010
0001
1000
0100
0010
0001
;
Both measures take the same amount of time, but the second one has 16ths, and the first one has 4ths. Also note that a comma signifies the end of a measure, and semicolons signifies the end of a chart.
Yesssss is offline   Reply With Quote
Old 09-27-2007, 07:03 PM   #5
jyris1
FFR Player
 
jyris1's Avatar
 
Join Date: Oct 2006
Posts: 133
Default Re: Parsing .sm files

Now that you have some idea of the structure of an SM file, on to programming: EDIT: You might end up using a variation of the following:

1. Find out how to open a file using whatever language.
2. Find out how to read and store ALL of the contents of said opened file, line by line.
3. For each line in the file, remove the comment "//" if any, because SM comments are unimportant data for parsing.
Also clean out unnecessary spaces and tabs in each line. Then store the cleaned line.
4. Group the cleaned lines together into a single string per SM tag. Hint - use the semicolon as a split point between commands.
(e.g., one group for tag "#BPMS" one group for tag "#NOTES", etc.)
5. Find out how to scan for a certain character(s) in a string, and keep the data that is not that character(s)
6. For each tag in #4, do #5 according to the way that tag handles data
(e.g., for "#GAP:XXX" take the number after the "colon", that's your gap,
for "#BPMS:XXX, XXX, XXX, XXX" extract all the BPM values between the commas and store them in a array/variable(s), those are your BPMs).

Any decent "How to program" book/website will give you information on #1-#5 in the book's "how to work with strings" and
"how to work with files" sections, and give you the actual command(s) to use.

There may be existing code (like an XML-type parser, or various existing string parsing functions, or SM's source code)
that may help you. If you code from scratch it might take ~100-300 lines for a basic sm parser.

And of course, test this to death, because the SM parser is the most straightforward bit of code in making such a game, yet the part most prone to error because of the sheer variation of SM files.

Hope that helps, and good luck.
__________________
I designed ddreamstudio.
The FFR Community has kindly compiled a ddreamstudio guide/downloads here-> http://goo.gl/nq5Ad

Last edited by jyris1; 09-27-2007 at 07:25 PM..
jyris1 is offline   Reply With Quote
Old 09-27-2007, 11:09 PM   #6
andrewshen123
FFR Player
 
Join Date: Jun 2005
Posts: 22
Send a message via MSN to andrewshen123
Default Re: Parsing .sm files

Thanks for the help. Oh and I already know how to program reasonably well, it's just the reading .sm files that I didn't understand.
andrewshen123 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:01 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution