Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Binery code (is difficult)

Author
Message
Bogboy2000
20
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 22nd Nov 2002 21:08
But not if you know how to work with it.

The question is how could i load any file into DB in binery and i mean absolutly anything, from .EXE to .DLL, .BMP to .MP3, ect.
Megaman X
20
Years of Service
User Offline
Joined: 21st Oct 2002
Location: Sweden
Posted: 22nd Nov 2002 22:37
That would be a lot of work. Like to re-invent the wheel It's better stick with a wheel already done

I don't suffer from insanity, I enjoy every minute of it.
-- Rogue
DrakeX
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 22nd Nov 2002 22:48
what do you mean by "load any file into DB in binary"?

what are you attempting to doo..?

you can open any file with OPEN FILE, but i have a feeling that's not what you mean. be more specific..

i'm looking at yooooou!
QuothTheRaven
20
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 23rd Nov 2002 05:55
in binary? you mean the crap jargon notepad spits out if you try to open a file thats not a word document? Why would you wanna deal with that horrible stuff? Even the programs that are meant to interprit that jargon dont deal with binary. If you open a dark basic file with notepad, you'll get lots of characters, assembly. but we already HAVE a program that knows what to do with them. Why make another?
striker25
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 23rd Nov 2002 09:23
you could dramatically speed up your programs if you coded in binary, because you would only code what was needed, and no extra paraphenalia.

Delta
20
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 23rd Nov 2002 12:31
QuothTheRaven,
That is not binary code, Binary is the absolute basic of all computer hmm "languages" its what every program is prosessed in, computers work in a series of on and off pulses, this is binary, its represented in a series of 0 and 1's, 0 is off 1 is on, binay code is grouped into 8 binary bits to make a byte

01101101 <- this is a byte of data



Delta
20
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 23rd Nov 2002 12:37
also have you ever tryed opening a word document in notepad? you acctualy get that "jargon" you where talking about :p notepad opens a file as it is (almost like a hex editor) notepad is for text documents or anything else that is not formated in any particular way (kinda)

simonuk74
20
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 23rd Nov 2002 12:46
Yes, Binary would be quicker, maybe A LOT QUICKER, but the problem is this..
you most probably have a 32 bit computer, so first, you need to learn the 32bit binary language, everything from :
00000000000000000000000000000000
to
11111111111111111111111111111111

and trust me, THERES LOADS!
more that you could easily work out!

Also the problem with binary, is that the computer understands it fine, but as far as I know there is no easy way of getting the computer to read it, that is why progs like dark basic exist.
if you were to code a game like halflife in binary, the code would be infinitly huge, for example `PLAY SOUND` command in binary would be MASSIVE.
there are loads of things that are done for you with compliers, like acessing memory addresses.

its very likley that Lee, Chris & Malcomb didnt write DB in binary, and it works quick enough. So theres no real need to use it!


Delta
20
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 23rd Nov 2002 14:23
When the automated phone srvice came about whenever something went wrong it woul print out a massive roll of binary! and people had to roll ot out, get on there hands and knees and READ IT! I doubt anyone could do sutch a job nowadays, luckly we dont realy need to!

This is why interpriters are used nowadays, its mutch easyer to read a short series of diffrent shapes than 0111010001101000011000010110111000100000011000010010000001101100011011110110111001100111001000000111001101100101011100100110100101100101011100110010000001101111011001100010000001101111011011100110110001111001001000000011001000100000011100110110100001100001011100000110010101110011

(ps that says than a long series of only 2 shapes)

an online binary translator
http://nickciske.com/tools/binary.php
Bogboy2000
20
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 24th Nov 2002 15:32
Finaly got round to replying

Delta, that's a good discription but not perfect, in the processor there are hundruds if components eched into i thin slither of silicon, each one of these can either be on ar off, hence 1 and 0. in short binary is the code which the computer does everything in, and every program ever made boils down to binery, and like Delta said 01101101 = 1 byte 8000 1s and 0s = 1 kb 8000000 1s and 0s = 1MB etc.

the reason i want to access binery code is because i'm planning on produceing something like Winzip, useing binary in a particular way to compact everything, i've got a method of compresing the data (in theory) but i need to be able to work with the binery data for the file in particular
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Nov 2002 16:56
Hmmm, not sure if this is any help, but here's the basics of binary.

On a piece of paper, write the following numbers along the top 128, 64, 32, 16, 8, 4, 2, 1. Now you can use this to calculate any 8-bit binary number, and calculate any integer value between 0 and 255. One important thing to remember, binary reads from right to left. Now take the binary number 01101101. Under each of the numbers you wrote on the piece of paper, write out the binary code under, so you'd have:

128=0, 64=1, 32=1, 16=0, 8=1, 4=1, 2=0, 1=1

Now, total all the numbers that have =1 after them. You should end up with 109, 109=01101101.

You can work out the binary for a number too, say 148 for example:

148-128=20
020-064=not possible
020-032=not possible
020-016=4
004-008=not possible
004-004=0
000-002=not possible
000-001=not possible

Now we can see that the number 128, 16, and 4 can all be subtracted in the binary sequence, so the binary for 148 would be 10010100.

The most common, every day use for binary conversions on a software level would be email. Every email attachment is converted 6-bit values, this is used to limit the bit width and release some 8 bit characters for special tasks. Most of the time, an attachment will end up about 30% bigger just by attaching it to an email.


Van-B
Bogboy2000
20
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 25th Nov 2002 20:27
Thanks Van B, but you answer still defers from the orrigional Q

How can I open any file into darkbasic as its binery information

for example, instead of loading a file then getting data from that file, you get the binery data of that (or any) file which you can then edit
TheCyborg
20
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 25th Nov 2002 23:31
I gues this is not what you wanted to hear, but...
As far as I know it's not possible without a custom dll.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2002 10:00
???

Huh? - When you load a file, you can ONLY view it as text, or ascii values, you could show the 8 bits for each byte, but why would you? - There is no way you'd want to edit a file on it's binary level, that's just daft.

You might want to consider a file editor. Just show 256 bytes at a time on a 16x16 grid, perhaps show the text and ascii/hex values for each byte, and make it possible to edit the file. This is more of a hacking tool than anything else, and there's loads available already (commonly referred to as hex editors). Coding a hex editor, or any file editor is possible with DB by using the READ BYTE, and WRITE BYTE commands, nothing complicated about loading and saving bytes in DB.


Van-B
Bogboy2000
20
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 26th Nov 2002 19:53
sorry just ignor me, I was being numb

what you do is

open to read 1,"slimb.sdl"
read byte 1,x

which opens the file you want and then get one byte from it which can then be converted to binery useing the method posted by Van B

my new method of compresion is to groupe every byte in a row that = 0 to become 0 times by the number of 0 there are
i.e

245,0,0,0,0,60,298,255,18,29,0,0,0,0,0,0,0

would become

245,B0,60,298,255,18,29,E0

A = 3
B = 4
C = 5
D = 6
E = 7
etc.

or something like that
TheCyborg
20
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 27th Nov 2002 09:48
Sounds good. Sounds Interresting. Sounds like it's gonna work.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
Killer Sponge
20
Years of Service
User Offline
Joined: 27th Nov 2002
Location: United Kingdom
Posted: 27th Nov 2002 17:07
Does Sound interesting, Not sure about the entire binary level email me and let me know how it goes

Bogboy2000
20
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 29th Nov 2002 19:35
NEW METHOD DEVELOPED

insted of what i previousley said

245,0,0,0,0,60,298,255,18,29,0,0,0,0,0,0,0

would become

245,B0,60,298,255,18,29,E0

A = 3
B = 4
C = 5
D = 6
E = 7

a sring of 0s in binery

0000000000000000

becomes

00001100

EXPLAINED

the first 0 is which binery number to it is 1 or 0
the other 7 give you up to 128 different posabillitys, to you could turn 16 bytes of 0s into one byte

the only problem with this is getting the program to recognise which bytes are compressed and which are not

because if you have C00001100 that is now 2 bytes meaning that you have to compress three or more bytes to make a difference

if any of you have any ideas please help
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Nov 2002 20:54
You'll need a marker. You have to check the file before hand and find a 16 bit value (2 bytes) that isn't used anywhere. This means you have to specify this when decompacting, so perhaps store it inside the compacted file so you can easily retrieve it. Now you have a marker that you can use to specify when a value is repeated. This obviously means you won't benefit unless theres at least 4 identical bytes in a row, but that's not unusual.

Say your marker is "--", and your only using a byte to specify the length, and the text your compacting is:

"anaansjjjjjjsdajjsirwoeeeeeeeowwewwwwwwwwwww"

The end result might look like:
"anaans--6jsdajjsirwo--7eowwe--bw"

Because "--6j" = 6 x "j". Saves 2 bytes out of 6.

This might not seem like a good compression, and it isn't, but it'd work fairly well for image files (and it'd protect them too).

I suggest looking up LZH compression techniques, it's pretty much the basis for all methods.


Van-B
TheCyborg
20
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 29th Nov 2002 21:55
What if the string contains "--"?

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Nov 2002 16:08
Well, the '--' has to be unique for every file, you'd have to search the file first and find a replacement '--' that hasn't been used. This might be slow, but if you made a function for searching the file with a passed string, you could have some presets, like guess a few rare combinations and pass them through first. If none of the presets work then you'd have to make up random strings till you found one. You then have to store this in the compressed file so your decompress code can get the marker string.


Van-B

Login to post a reply

Server time is: 2023-09-29 04:39:43
Your offset time is: 2023-09-29 04:39:43