here, i whipped this together. this should get you started on file structure.
rem RIFF Contents Viewer
rem (does not play/view media in any way)
rem copyright 2003 Ag3ntSm1th
rem this program is freeware. enjoy, otherwise go fuck yourself trying
dim filejunk$(10)
dim foundavis$(255)
dim dword$(4)
dim junk(10)
rem -------------------------------------------------------------------------
rem Call functions to initialize program
rem -------------------------------------------------------------------------
settings()
pickfile()
rem -------------------------------------------------------------------------
rem Main loop
rem -------------------------------------------------------------------------
do
sync
loop
rem -------------------------------------------------------------------------
rem These are general program settings
rem -------------------------------------------------------------------------
function settings()
sync on
hide mouse
randomize timer()
draw to front
set text transparent
set text size 12
set text font "arial"
endfunction
rem -------------------------------------------------------------------------
rem Pick a file to open in current directory
rem -------------------------------------------------------------------------
function pickfile()
d=1
rem change this to wherever you have sample avi's
set dir ""
for clear=0 to 255
foundavis$(clear)=""
next clear
find first
repeat
if get file type()=0
temp$=get file name$()
fileext$=right$(temp$,4)
endif
rem you can change fileext$ to any supported RIFF file type
rem in our case it'll be ".avi"
if fileext$=".avi"
foundavis$(d)=temp$
d=d+1
endif
find next
until get file type()=-1
max=d
d=1
begin:
cls
ink rgb(255,255,255),rgb(0,0,0)
text 1,1,"Use up and down to scroll through files that were found."
text 1,11,"Press enter to view the contents of selected file."
ink rgb(255,255,0),rgb(0,0,0)
text 2,21,foundavis$(d)
repeat
if upkey()=1 and d>1 then d=d-1: sleep 100: goto begin
if downkey()=1 and d<max-1 then d=d+1: sleep 100: goto begin
sync
until returnkey()=1
filejunk$(1)=foundavis$(d)
open to read 1, filejunk$(1)
main$=""
rem this gets either "RIFF" or "RIFX" for endian notation (i think its called)
for riffget=1 to 4
read byte 1, rb:rb$=chr$(rb)
main$=main$+rb$
next riffget
filejunk$(2)=main$
rem this gets the size of all chunk data (not including padded data after media)
for datasize=1 to 4
read byte 1, rb
if filejunk$(2)="RIFX"
dword$(datasize)=bytetobinary(rb)
endif
if filejunk$(2)="RIFF"
dword$(5-datasize)=bytetobinary(rb)
endif
next datasize
dwordtodecimal()
rem get what type of media is in the chunks
for typeget=1 to 4
read byte 1, rb:rb$=chr$(rb)
filetype$=filetype$+rb$
next typeget
filejunk$(4)=filetype$
text 1,41,"RIFF/RIFX : "+filejunk$(2)
text 1,51,"Data size : "+filejunk$(3)
text 1,61,"File type : "+filejunk$(4)
text 1,71,""
close file 1
endfunction
rem -------------------------------------------------------------------------
rem Change a byte (of decimal nature) into an 8bit binary sting
rem -------------------------------------------------------------------------
function bytetobinary(byte)
if byte>127
bit7$="1"
byte=byte-128
else
bit7$="0"
endif
if byte>63
bit6$="1"
byte=byte-64
else
bit6$="0"
endif
if byte>31
bit5$="1"
byte=byte-32
else
bit5$="0"
endif
if byte>15
bit4$="1"
byte=byte-16
else
bit4$="0"
endif
if byte>7
bit3$="1"
byte=byte-8
else
bit3$="0"
endif
if byte>3
bit2$="1"
byte=byte-4
else
bit2$="0"
endif
if byte>1
bit1$="1"
byte=byte-2
else
bit1$="0"
endif
if byte>0
bit0$="1"
byte=byte-1
else
bit0$="0"
endif
binary$=bit7$+bit6$+bit5$+bit4$+bit3$+bit2$+bit1$+bit0$
endfunction binary$
rem -------------------------------------------------------------------------
rem Change 4 binary strings provided by bytetobinary() into a decimal number
rem -------------------------------------------------------------------------
function dwordtodecimal()
for a=1 to 4
dword$=dword$+dword$(a)
next a
total=0
for b=32 to 1 step -1
if mid$(dword$,b)="1" then total=total+(2^((32-b)))
next b
filejunk$(3)=str$(total)
endfunction total
I'll keep working on this but in the meantime keep studying and collecting docs.
good luck
"The secret to creativity is knowing how to hide your sources." - Einstein