I have tried differend option and all option is coming out to work slow and/or corrupt the file.
1. i try to read in a file (.bmp) byte per byte. Run a XOR the byte and write it to a big file. (file size 750 Kb) that is not that big. Took DBP 21 minute to read code and write.
2. Read DWORD in XOR it and write it to a big file. Toke DBP 19 minutes to read code and write.
3. Make memblock of total file, read file in to memblock (went very fast),Then coding XOR byte per byte. toke DBP 27 minutes to code the file. Then writing to big file( also very fast) But there where some extra byte in the big file i do not need.
4. Same as 3 but now XOR DWORD took even langer then 29 minutes, with the same results.
It is stranges why DBP is going so SLOOOW with data coding. I wanted to make a program that easly switch between full screen and windowed view. That is DBP strong point. Everything else is working like a charm.
The code is:
`Makebitmap
`CreateBitmap.dba
`============================================================================
`program name :BitmapDat.exe
`Version :1.00
`Build :0001
`auther :B.J.Fernhout.
`Company :B&K WORKS (c) 2004 - 20016
`Discription :Make a big dat file from a text file combining all names
` :and code them to one big file.
`=============================================================================
`set globals
global screen_width = 640
global screen_height = 480
global screen_depth = 32
`File numbering for easy acces
global read_file = 1
global write_file = 2
`init the screen only window mode to show progress
set display mode screen_width,screen_height,screen_depth
set window on
set window layout 4,1,1
sync off
dim list_of_names(1024) as string
dim length_of_file(1024) as integer
open to read 1,"list.txt"
list_pointer = 0
`read all names of the bitmap
while file end(1) = 0
read string read_file,list_of_names(list_pointer)
inc list_pointer
endwhile
close file read_file
`read length every file
list_pointer = 0
While list_of_names(list_pointer) <> ""
length_of_file(list_pointer) = file size(list_of_names(list_pointer)+".bmp")
Print list_of_names(list_pointer)+".bmp" +" --> Lengte : " + str$(length_of_file(list_pointer))
inc list_pointer
endwhile
`if file already exist remove it
if file exist("Graphfile.dat")
delete file ("Graphfile.dat")
endif
`read and write new dat file
Print "Open file --- to write data ---"
open to write write_file,"Graphfile.dat"
write word write_file,list_pointer-1
list_pointer = 0
While list_of_names(list_pointer) <> ""
`write the file name excluding extension
print "Filename writing : " + list_of_names(list_pointer)
Write Byte write_file,Len(list_of_names(list_pointer))
`coding text the easy way
For y = 1 To Len(list_of_names(list_pointer))
temp = Asc(Mid$(list_of_names(list_pointer),y))
temp = temp Xor 0xFF
Write Byte write_file,temp
Next y
`Show file length
Print "Coded"
Print "File length writing : " + str$(length_of_file(list_pointer))
temp = length_of_file(list_pointer)
tex$ = str$(length_of_file(list_pointer))
write byte write_file,len(tex$)
`write file length
For y = 1 To Len(tex$)
temp = asc(Mid$(tex$,y))
temp = temp Xor 0xFF
Write Byte write_file,temp
Next
Print "Coded"
Print "File data writing and coding"
`open to read graphic file
make memblock 1,length_of_file(list_pointer)
make memblock 2,length_of_file(list_pointer)
if memblock exist(2)
print "ok"
else
` end
endif
mem_pointer = 0
load image list_of_names(list_pointer)+".bmp",1,1
make memblock from image 2,1
`open to read read_file,list_of_names(list_pointer)+".bmp"
`read memblock read_file,2
`while file end(read_file) = 0
`read byte read_file,a
`write memblock byte 2,mem_position,a
`inc mem_position
`endwhile
while mem_pointer < length_of_file(list_pointer)
` break
xx = memblock dword (2,mem_position)
xx = xx xor 0xFFFFFFFF
write memblock dword 1,mem_pointer,xx
if mem_pointer mod 1500 = 0
print ".";
`print str$(mem_pointer) + " : " +str$(length_of_file(list_pointer))
endif
inc mem_pointer,4
`Write Byte write_file,xx
Endwhile
Print "Coded"
Close File read_file
`write block to file
Write Memblock write_file,1
delete memblock 1
delete memblock 2
`next file to coding
Inc list_pointer
endwhile
close file write_file
Print "Writing and coding done. "
Print "Press any key or mouse to exit program."
while scancode() = 0
endwhile
the file is everything xoring. I want to do this cause the graphics are still changing and to minimize the download (And a low space of storage on my site) i can update the graphics then.
I can not have this time when a program is starting up and start reading the big file to recode all data. An the program is taking 26 minutes te decode.
I have done this also in Blitz3DBasic and to my supprise the compilled program is doing this jou in 22 sec and creating a big file of 21 MB. Testing it by letting the big file decoding back to original files this one take 35 sec.
Now why can't DBP do this.
Dont tell me that the read write to a disk is the problem because if that wat true then Blitz3DBasic must have been slow to!!
Games is live so to live do the games