Converting .BIN files to .PRG (Split/moved from HW/Tech)

Basic and Machine Language

Moderator: Moderators

User avatar
Boray
Musical Smurf
Posts: 4026
Joined: Mon May 03, 2004 10:47 am

Postby Boray » Fri Jul 21, 2006 1:54 am

eslapion wrote:Doing the file the way you tell me seems to work as it created a new file with 2 extra bytes at the beginning, however the result is also a sequential file and not a prg.


It produces a PRG and my program also have some advantages:
1. You can choose ANY destination address, including the basic memory occupied by the converter.
2. Runs on any 8-bit Commodore.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)

User avatar
Boray
Musical Smurf
Posts: 4026
Joined: Mon May 03, 2004 10:47 am

Postby Boray » Fri Jul 21, 2006 1:55 am

Jeff-20 wrote:
Boray wrote:Maybe some moderator should move this topic to the programming forum?


Are you not a mod in this forum? :lol: :wink:


Well, I would have moved the topic instead of splitting it :wink:
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)

tlr
Vic 20 Afficionado
Posts: 438
Joined: Mon Oct 04, 2004 10:53 am

Postby tlr » Sat Jul 22, 2006 3:06 am

eslapion wrote:
tlr wrote:If you are on a unix-like system you could do this...

bin2prg:

Code: Select all

echo -e -n '\x00\x40' | cat - file.bin > file.prg

(load addr $4000 in the example)

prg2bin:

Code: Select all

dd if=file.prg of=file.bin bs=1 skip=2

(any load addr)


Sorry, I am a slave to Bill... I'm a Windows guy and I don't even know how to make programs under that OS...

No need for slavery...
Just install MSYS or Cygwin and you'll be fine. ;)

eslapion
ultimate expander
Posts: 4275
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Postby eslapion » Tue Jul 25, 2006 1:49 am

Well,
Here is another challenge for you guys I didn't anticipate but... I should have, it makes perfect sense.

I have a 64kBytes .BIN file. Now, the memory of a VIC or 64 will not allow you to load all that at once in the computer. I need a piece of software that would convert this single .BIN file into either two 32kBytes .PRG files or four 16kBytes .PRG files.

Do you guys think this is feasible?

User avatar
Mike
Herr VC
Posts: 3002
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Tue Jul 25, 2006 3:46 am

eslapion wrote:I need a piece of software that would convert this single .BIN file into either two 32kBytes .PRG files or four 16kBytes .PRG files.

If you don't want the *.prg header, omit line 40.

Code: Select all

10 OPEN2,8,2,"BIGFILE.BIN,P,R"
20 N$=CHR$(0):FORT=0TO3
30 OPEN3,8,3,"SPLIT"+CHR$(48+T)+",P,W"
40 PRINT#3,CHR$(0)CHR$(64*T);
50 FORS=0TO16383:GET#2,A$:PRINT#3,LEFT$(A$+N$,1);:NEXT
60 CLOSE3
70 NEXT
80 CLOSE2

So far, no big problem, and possibly easier done outside the CBM environment, but ...
eslapion wrote:Do you guys think this is feasible?

... the big question remains, whether these .PRG files are really useful. You can't load them the normal way, as they would overwrite ZP, I/O, the loader (the loader might not be affected, if it is part of the *.BIN file).

So if the purpose of the *.BIN file is to re-load the entire memory-state, a *little* more work is needed than splitting the *.BIN file into *.PRG files.

I remember, that I once wrote a loader to fill the RAM addresses 1024-65535 on a C64 from such a long file. The loader resided in the stack. I used a simple program to start the C64 mode on a C128 in Bank 1 [*]. All addresses 1024-65279 were retained when with a reset back to C128, then saved to disc. Another program saved addresses 65280-65535 in C64 mode (therefore, a second start of the program to be saved was needed). A third program appended these two files. Finally I just needed to determine the starting address of the game by hand (most of the time something like $x000, and starting with: SEI, LDX#&FF, TXS, init background and border :) ).

Michael

[*] Poor man's freezer. ;)

User avatar
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Postby carlsson » Tue Jul 25, 2006 5:55 am

If he's going to load only one 16-32K chunk at a time - it was said that these computers can't handle a 64K image - the load address is not really interesting. Furthermore, I tend to remember this was about preparing files to be burned to EPROMs. Is the goal to make 64K EPROMs which you can select smaller chunks out of? Something like a multicart on a Flash ROM?
Anders Carlsson

Image Image Image Image Image

eslapion
ultimate expander
Posts: 4275
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Postby eslapion » Tue Jul 25, 2006 1:07 pm

carlsson wrote:If he's going to load only one 16-32K chunk at a time - it was said that these computers can't handle a 64K image - the load address is not really interesting. Furthermore, I tend to remember this was about preparing files to be burned to EPROMs. Is the goal to make 64K EPROMs which you can select smaller chunks out of? Something like a multicart on a Flash ROM?


The purpose is to convert a 64k .BIN file I have on the PC to two manageable 32k .PRG files on the 64 side so I can burn the necessary 27c512 EPROMs for making replacement PLAs for the 64 using Schema's method.

The load address would either be $1000 or $2000 so it doesn't overwrite I/O adresses and the likes... on a 64.

If I was to work with a VIC then I would have to do it with 4 x 16k files.

tlr
Vic 20 Afficionado
Posts: 438
Joined: Mon Oct 04, 2004 10:53 am

Postby tlr » Tue Jul 25, 2006 2:08 pm

eslapion wrote:I have a 64kBytes .BIN file. Now, the memory of a VIC or 64 will not allow you to load all that at once in the computer. I need a piece of software that would convert this single .BIN file into either two 32kBytes .PRG files or four 16kBytes .PRG files.


32k:

Code: Select all

dd if=file64k.bin of=file32k_01.bin bs=1 skip=0 count=32K
dd if=file64k.bin of=file32k_02.bin bs=1 skip=32K count=32K


16k:

Code: Select all

dd if=file64k.bin of=file16k_01.bin bs=1 skip=0 count=16K
dd if=file64k.bin of=file16k_02.bin bs=1 skip=16K count=16K
dd if=file64k.bin of=file16k_03.bin bs=1 skip=32K count=16K
dd if=file64k.bin of=file16k_04.bin bs=1 skip=48K count=16K


...and then conv to prg by above method.
Last edited by tlr on Tue Jul 25, 2006 2:13 pm, edited 1 time in total.

User avatar
Schema
factor
Posts: 1408
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Postby Schema » Tue Jul 25, 2006 2:13 pm

Yeah, the Promenade manual (I am borrowing 6502dude's right now) tells you to burn 27C512's in two steps, and to force the highest address pin to ground or 5V with a piece of wire :lol:

For manipulating the files...I adore my VIC, but some things are just easier on a PC. I like WinHex:

http://www.x-ways.net/winhex/

Just split the .BIN into two 32K chunks, prefix it with 00 20, and you're done!

User avatar
6502dude
megacart
Posts: 1575
Joined: Wed Dec 01, 2004 9:53 am

Postby 6502dude » Tue Jul 25, 2006 2:23 pm

If PC based eprom burner is available, this would be easiest solution to burn the 27512 eprom.

In the past when I was stuck only with Promenade, I split files on PC with hex editor, loaded into C128 with MLM and burned 32k chunks at a time.

Once, I restored a pc system bios once this way when user flashed with wrong bios for mother board. :oops:

I restored to a 27010 eprom (four 32K chunks). Using eprom prevented recurrance of user boo boo.
Image Mega-Cart: the ultimate cartridge for your Commodore Vic-20

eslapion
ultimate expander
Posts: 4275
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Postby eslapion » Tue Jul 25, 2006 3:40 pm

I put a small switch in my Promenade to do the short Schema mentioned.

Right now, WinHEX seems the easiest and least time consuming method. However, I downloaded it without paying for it. Will it ever cease to function and require registration ?

User avatar
6502dude
megacart
Posts: 1575
Joined: Wed Dec 01, 2004 9:53 am

Postby 6502dude » Tue Jul 25, 2006 7:31 pm

I use Nitrohex:
http://www.freedownloadscenter.com/Prog ... ditor.html (trialware 30 day)

or ProgStudio 6
http://www.batronix.com/electronic/down ... bler.shtml
(crippleware for burning eproms beyond 256bytes - otherwise ok)

Both are worth the registration fee.

But, there are a few free hex editors available as well.
Image Mega-Cart: the ultimate cartridge for your Commodore Vic-20

User avatar
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Postby carlsson » Wed Jul 26, 2006 9:12 am

256 bytes EPROMs? Surely you meant 256 kilobyte?
Anders Carlsson



Image Image Image Image Image

User avatar
6502dude
megacart
Posts: 1575
Joined: Wed Dec 01, 2004 9:53 am

Postby 6502dude » Wed Jul 26, 2006 11:29 am

carlsson wrote:256 bytes EPROMs? Surely you meant 256 kilobyte?


Yes, it is a 256 Byte limitation.

Software is limited (crippleware) to only burn first 256 bytes of any eprom. Vendor does this to allow you to verify software works.

Once you register software, the limit problem goes away.

I have used software to write to 2 & 4 Mbit flashes as well as many 27256 & 27512 eproms.

If not burning eproms or flashes, the unregistered software works fine as a zero cost hex editor.
Image Mega-Cart: the ultimate cartridge for your Commodore Vic-20

eslapion
ultimate expander
Posts: 4275
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Postby eslapion » Thu Jul 27, 2006 5:55 pm

Thank you all people. You have all come up with varied but just as effective solutions.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest