News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_EgoTrip

[cpctelera] Hex2Bin alternative?

Started by EgoTrip, 22:42, 24 October 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EgoTrip

I tried to use Hex2Bin to convert a file to c format but it won't work. It completely locked up my PC and I lost a fair bit of work so theres no way I'm loading that piece of crap up again. Is there anything else that does the same job? I tried to write a BASIC program that dumped the data to printer in WinAPE but for some reason it stops before it reaches the end of the data.

ronaldo

#1
Excuse me, @EgoTrip, I don't understand what you were trying to do and what is exactly the problem. Can you describe it in other way? Take into account that I'm spanish and may missunderstand things sometimes.

Hex2bin is used normally to convert IHX binary format produced by SDCC into AMSDOS binary format.I've never used it to convert a binary to C format.

ervin

Quote from: EgoTrip on 22:42, 24 October 15
I tried to use Hex2Bin to convert a file to c format but it won't work. It completely locked up my PC and I lost a fair bit of work so theres no way I'm loading that piece of crap up again. Is there anything else that does the same job? I tried to write a BASIC program that dumped the data to printer in WinAPE but for some reason it stops before it reaches the end of the data.

@EgoTrip - are you simply trying to convert hex data to a C array?
If so, you're likely looking for cpct_bin2c.

For example, I converted a number of exomized files into C arrays (for inclusion in my game RUNCPC) like this:


cpct_bin2c a.exo > a.c


Fessor

Or, if not so into CLI-Tools, use a Hexeditor with Export-Function.

Under Linux i can recommend Okteta (Hexeditor) as it can export Data as C-Array (and many other Formats)

For Windows maybe this http://mh-nexus.de/en/hxd/
QuoteExporting of data to several formats

       
  • Source code (Pascal, C, Java, C#, VB.NET)
  • Formatted output (plain text, HTML, Richtext, TeX)
  • Hex files (Intel HEX, Motorola S-record)

GeoffB17

I also don't know what your question means.

I understand you're using a PC.

In this environment, a HEX file is a sort of binary file (which might be produced as an intermediate stage by some compilers) which contains mostly binary data but in a two character text format rather than as 1 byte per byte true binary file.   The content of a HEX file would be a bit like the output of the DUMP utility, the benefit is that it is readily human readable.   There are very specific formats for the data, for example INTEL format.

HEX2BIN would read in the data from the HEX file, detect the actual binary data from within the text, and output a BIN file of that same binary data - the BIN file being in effect a .COM executable, although I think I've seen reference to needing a BIN2COM as well?

If the format of the HEX data in the HEX file is not correct for the version of HEX2BIN that you're using, I'd think the prog might error, or even hang, but I don't see why any data should be lost.   The process merely takes data in TEST.HEX and creates TEST.BIN.

Your reference to 'c format' is a total mystery!

Where has the HEX file come from?   What format is it.   Where has HEX2BIN come from.   What command line are you using (paramaters, special options ?)

Geoff

arnoldemu

#5
@EgoTrip: Hex2Bin is not the correct program for this.

"hex to bin" is not "bin to c" ;)

This is the one: cpct_bin2c

I am suprised hex2bin locked up your PC (logging out didn't fix it? task manager and then log-out??? no need to power off now, windows 7,8 and 10 do a fair job at allowing you to stop programs, and if not logging out and back in again normally does it) but not that it produced the wrong result.

A lot of programs can do the wrong thing if given the wrong data -hex2bin seems to be one of them. Programs are not always written to verify their input data and handle unexpected or wrong input. It takes effort for a programmer to put this verification in, and often it's easier not to if the programmer believes the program will never be given unexpected data.

Loosing data is never good - it happens to all of us and we all curse when it happens. You're not alone here.

Make frequent backups, maybe just zipping up your directory often, then when things like this happen it's not so bad.

At work we use source control to avoid these problems. The source control helps keep revisions so we can undo work if we want giving the freedom to experiment if needed (and go back to a known good version), and to have history and a backup - another good reason for development on a pc :)

For simple source control I recommend "fossil". It runs on windows, linux and mac.

Fossil: Home

You can run it on your own pc (no admin or network setup required) and it's simple to use although it is command-line based.

EgoTrip

I'm an idiot.  :picard2:

I hate command line tools anyway and that hxd tool does the job for me, thanks.

EgoTrip

Quote from: arnoldemu on 07:56, 25 October 15
I am suprised hex2bin locked up your PC (logging out didn't fix it? task manager and then log-out??? no need to power off now, windows 7,8 and 10 do a fair job at allowing you to stop programs, and if not logging out and back in again normally does it) but not that it produced the wrong result.

It was a complete lock, nothing was responsive at all and I had to switch it off and back on.

I usually do a good job of backing up, I make a copy of the working disk/folder every so often. It wasn't the code I lost tho it was front end stuff I had open in paint.net

arnoldemu

#8
Quote from: EgoTrip on 08:32, 25 October 15
I hate command line tools anyway and that hxd tool does the job for me, thanks.
You are not alone.

Most designers and artists hate them too. I know some programmers that are not keen on them.

Command-line tools are very common in the linux world, so linux users are used to them. Most window's or mac users I would say prefer a nice UI to use.

(Adding a UI can take time especially if the tool is meant to be used on linux, mac and windows. Sometimes UIs are not always well designed too ;) )

arnoldemu

Quote from: EgoTrip on 08:35, 25 October 15
It was a complete lock, nothing was responsive at all and I had to switch it off and back on.

I usually do a good job of backing up, I make a copy of the working disk/folder every so often. It wasn't the code I lost tho it was front end stuff I had open in paint.net
I hate those kinds of lock ups. Especially when my own code causes them ;)

Good news on the backups :)

Does paint.net have a timed auto-save feature? If it does it may be worth enabling it.


ronaldo

Quote from: EgoTrip on 08:32, 25 October 15
I hate command line tools anyway and that hxd tool does the job for me, thanks.
@EgoTrip: If you are using the latest version of CPCtelera, any file you put under your /src folder with .bin extension will be autoconverted to .c array when you run make. No need to manually use command line tools for this :).

Also, if you do it this way, every time you update the binary file, it will be autoconverted again.

ervin

Quote from: ronaldo on 08:42, 25 October 15
@EgoTrip: If you are using the latest version of CPCtelera, any file you put under your /src folder with .bin extension will be autoconverted to .c array when you run make. No need to manually use command line tools for this :) .
Also, if you do it this way, every time you update the binary file, it will be autoconverted again.

Oooh, this would have been wonderful during RUNCPC's development!!!
:)

Powered by SMFPacks Menu Editor Mod