Shannon Posted February 26, 2008 Share Posted February 26, 2008 (edited) Anyone know of a program that can convert data from a file into C code that stores that data into an array. Preferably one that can be run on a PC. Thanks.. Edited February 26, 2008 by Shannon Quote Link to comment Share on other sites More sharing options...
Urchlay Posted February 26, 2008 Share Posted February 26, 2008 Anyone know of a program that can convert data from a file into C code that stores that data into an array. Preferably one that can be run on a PC. I wrote one not long ago in C... here's the source. Public domain code, use how you like. blob2c_20080226.zip Quote Link to comment Share on other sites More sharing options...
Shawn Jefferson Posted February 27, 2008 Share Posted February 27, 2008 I wrote a program like that once, but never used it, since I realized that cc65 has a way to include binary data... I don't know if that is what you are using or not (guessing since you asked the question in here). Look at .incbin: http://www.cc65.org/doc/ca65-10.html#ss10.59 Quote Link to comment Share on other sites More sharing options...
Urchlay Posted March 1, 2008 Share Posted March 1, 2008 I wrote a program like that once, but never used it, since I realized that cc65 has a way to include binary data... I wrote mine for a project where I needed to include Atari 6502 code in a program written to run on Linux... gcc doesn't have incbin. Haven't heard back from the original poster, dunno whether he found it useful or not. Quote Link to comment Share on other sites More sharing options...
Shannon Posted March 1, 2008 Author Share Posted March 1, 2008 Sorry... I just had not had the time to try anything yet. But I should be sooner or later. I have three items I need to convert eventually. Still hashing out the code that will use the. Quote Link to comment Share on other sites More sharing options...
HiassofT Posted March 2, 2008 Share Posted March 2, 2008 You may also use the "xxd" program from the Vim package. It's available on most Linux systems (if you have vim installed) and also on Windows: go to http://www.vim.org/download.php and get the latest gvimXX.exe (currently gvim71.exe). With xxd creating C-style arrays is really simple (I use it quite often in my Makefiles): xxd -i infile outfile so long, Hias Quote Link to comment Share on other sites More sharing options...
Shannon Posted March 2, 2008 Author Share Posted March 2, 2008 Hey thanks, that'll probably be easier. My compile environment is currently set-up for Xbox. I'm not sure how to compile something to run under DOS just yet. I'm still testing on the actual files right now but eventually want to integrate a few of them into the code itself. Quote Link to comment Share on other sites More sharing options...
Shannon Posted March 8, 2008 Author Share Posted March 8, 2008 Thanks I was able to convert a file over earlier in the week and everything compiled just fine. So I should be good to go. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.