
http://en.wikipedia.org/wiki/DOS_executableAr-S a écrit :ça affiche bien MZ effectivement, mais c'est quoi au juste ? Un genre de Header pour les exe pc ??
http://en.wikipedia.org/wiki/DOS_executableAr-S a écrit :ça affiche bien MZ effectivement, mais c'est quoi au juste ? Un genre de Header pour les exe pc ??
Merci, décidément y'a vraiment tout sur wikipediadjes a écrit :Thyphoon> Super intéressant tout ça, merci! Sur le forum anglais il y a d'autres développeurs de jeu "pro", ou assimilés. Je trouve toujours leur expérience intéressante
http://en.wikipedia.org/wiki/DOS_executableAr-S a écrit :ça affiche bien MZ effectivement, mais c'est quoi au juste ? Un genre de Header pour les exe pc ??
Code : Tout sélectionner
; amiga .info reader
; par case 2008
;-------------------
InitSprite()
main=OpenWindow(#PB_Any,0,0,400,400,"")
OpenWindowedScreen(WindowID(main),0,0,400,400,0,0,0)
; ---- big endian related fonctions ----
Structure diskobject_struct
do_magic.w
do_version.w
do_gadget_next_gadget.l
do_Gadget_LeftEdge.w
do_Gadget_topEdge.w
do_Gadget_width.w
do_Gadget_height.w
do_Gadget_flags.w
do_Gadget_activation.w
do_Gadget_gadgettype.w
do_Gadget_gadgetrender.l
do_Gadget_selectrender.l
do_Gadget_gadgettext.l
do_Gadget_MutualExclude.l
do_Gadget_specialinfo.l
do_Gadget_gadgetid.w
do_Gadget_userdata.l
do_type.b
padding.b
do_DefaultTool.l
do_ToolTypes.l
do_CurrentX.l
do_CurrentY.l
do_DrawerData.l
do_Toolwindow.l
do_StackSize.l
EndStructure
Structure drawerdata_struct
dd_NewWindow_LeftEdge.w
dd_NewWindow_TopEdge.w
dd_NewWindow_Width.w
dd_NewWindow_Height.w
dd_NewWindow_DetailPen.b
dd_NewWindow_BlockPen.b
dd_NewWindow_IDCMPFlags.l
dd_NewWindow_Flags.l
dd_NewWindow_FirstGadget.l
dd_NewWindow_CheckMark.l
dd_NewWindow_Title.l
dd_NewWindow_Screen.l
dd_NewWindow_BitMap.l
dd_NewWindow_MinWidth.w
dd_NewWindow_MinHeight.w
dd_NewWindow_MaxWidth.w
dd_NewWindow_MaxHeight.w
dd_NewWindow_Type.w
dd_CurrentX.l
dd_CurrentY.l
;------- used for amiga os 2.x+ only
dd_Flags.l
dd_ViewModes.w
EndStructure
Structure image_struct
leftedge.w
topedge.w
width.w
height.w
depth.w
imagedata.l
planepick.b
planeonoff.b
nextimage.l
EndStructure
Declare peekbyte(adress)
Declare peekword(adress)
Declare PeekLong(adress)
Declare endianconvert(str$,*buffer1,*buffer2,offset)
; ---- function that decode an icon
Declare decodeicon(filename$)
; ---- structures ----
Declare showicon(xx,yy,buffer,offset,nfo,revision)
;********************************************
; changer la ligne suivante avec le chemin vers une icone amiga valide :)
;********************************************
adress=decodeicon("Whats_new.txt.info")
;
;********************************************
;********************************************
Global diskobject.diskobject_struct
Global drawerdata.drawerdata_struct
Global image.image_struct
Global image2.image_struct
Global offset
Global offsetpicture1.l,offsetpicture2.l
;
;-----------------------------------------PICTURE DATA---------------------
row_bytes=((image\Width + 15) >> 4) << 1 ; size in bytes of a row of pixel
planesize=row_bytes*image\height ; size in bytes of a plane
Global Dim col(11)
; wb 1
col(00)=RGB(85,170,255)
col(01)=RGB(255,255,255)
col(02)=RGB(0,0,0)
col(03)=RGB(255,136,0)
; wb 2
col(04)=RGB(149,149,149)
col(05)=RGB(0,0,0)
col(06)=RGB(255,255,255)
col(07)=RGB(59,103,162)
;
; + magic wb
col(08)=RGB(123,123,123)
col(09)=RGB(175,175,175)
col(10)=RGB(170,144,124)
col(11)=RGB(255,169,151)
;
showicon(0,0,adress,offsetpicture1,@image,diskobject\do_Gadget_userdata)
showicon(50,0,adress,offsetpicture2,@image2,diskobject\do_Gadget_userdata)
Repeat
FlipBuffers()
WaitWindowEvent(100)
ForEver
End
Procedure showicon(xx,yy,buffer,offset,*var,revision)
nfo.image_struct
CopyMemory(*var,@nfo,SizeOf(nfo))
If revision=1 ; use the wb2 palette
cbase=4
EndIf
;
row_bytes=((nfo\Width + 15) >> 4) << 1
planesize=row_bytes*nfo\height
For y=0 To nfo\height-1 ; for each line
For x=0 To row_bytes-1 ; read each bytes
For pix=1 To 8 ; decode each pixel
color=cbase
For plane=1 To nfo\depth ; read each plane
planesh=(plane-1)*planesize
;
adr=buffer+offset+(x+(y*row_bytes))+planesh
oct=PeekB(adr) & $ff
thisbit=(( (oct >> (pix-1)) & 1) << (plane-1))
color=color+thisbit
Next
StartDrawing(ScreenOutput())
If x*8+8-pix < nfo\width
Plot(xx+x*8+8-pix,yy+y,col(color))
EndIf
StopDrawing()
Next
Next
Next
EndProcedure
Procedure decodeicon(filename$)
fsize=FileSize(filename$) ; get the size of the icon
*buffer1=AllocateMemory(fsize) ; allocate memmory for the original icon in amiga big endian format
rd=ReadFile(#PB_Any,filename$) ; open the file
ReadData(rd,*buffer1,fsize) ; read the dtat of the icon to the memory
CloseFile(rd) ; close the file
*buffer2=AllocateMemory(fsize) ; allocate memory for the icon in little endian format
diskobj$ ="22422222224444424114444444" ; 1=byte,2=word,4=long
drawerdata1$ ="22221144444442222244" ; tables For each structures
drawerdata2$ ="2222114444444222224442" ;
imagestructure$="222224114" ;
;
offset=0
newoffset=endianconvert(diskobj$,*buffer1,*buffer2,offset)
CopyMemory(*buffer2+offset,@diskobject,78) : offset=newoffset
;
If diskobject\do_DrawerData<>0 ; there's a drawer data structure
; check version wb 1.x or 2.x
If diskobject\do_Gadget_userdata=0
newoffset=endianconvert(drawerdata1$,*buffer1,*buffer2,offset)
Else ; os 2.0 +
newoffset=endianconvert(drawerdata2$,*buffer1,*buffer2,offset)
EndIf
EndIf
CopyMemory(*buffer2+offset,@drawerdata,newoffset-offset):offset=newoffset
; image 1 structure
newoffset=endianconvert(imagestructure$,*buffer1,*buffer2,offset)
CopyMemory(*buffer2+offset,@image,20):offset=newoffset
offsetpicture1=offset ; definit l'adresse de l'image 1
row_bytes=((image\Width + 15) >> 4) << 1 ; size in bytes of a row of pixel
planesize=row_bytes*image\height ; size in bytes of a plane
picturesize=planesize*image\depth
CopyMemory(*buffer1+offset,*buffer2+offset,picturesize)
offset=offset+picturesize
If diskobject\do_Gadget_selectrender<>0 ; second picture
newoffset=endianconvert(imagestructure$,*buffer1,*buffer2,offset)
CopyMemory(*buffer2+offset,@image2,20):offset=newoffset
offsetpicture2=offset
row_bytes=((image2\Width + 15) >> 4) << 1 ; size in bytes of a row of pixel
planesize=row_bytes*image2\height ; size in bytes of a plane
picturesize=planesize*image2\depth
CopyMemory(*buffer1+offset,*buffer2+offset,picturesize)
offset=offset+picturesize
EndIf
CopyMemory(*buffer1,*buffer2,fsize-offset)
Debug Hex(PeekB(*buffer2+offset))
;
Repeat
a$=""
offset=offset+1
str=PeekB(*buffer2+offset)
If str<>$74 And str<>0
For a=1 To str-1
offset=offset+1
a$=a$+Chr(PeekB(*buffer2+offset))
Next a
Debug a$
EndIf
Until offset=fsize
FreeMemory(*buffer1)
ProcedureReturn *buffer2
EndProcedure
Procedure peekbyte(adress)
ProcedureReturn PeekB(adress) &255
EndProcedure
Procedure peekword(adress)
ProcedureReturn (PeekByte(adress) <<8 + PeekByte(adress+1))
EndProcedure
Procedure peeklong(adress)
ProcedureReturn PeekByte(adress)<<24 + peekbyte(adress+1)<<16+ peekbyte(adress+2)<<8+ peekbyte(adress+3)
EndProcedure
Procedure endianconvert(str$,*buffer1,*buffer2,offset)
For a=1 To Len(str$)
Select Mid(str$,a,1)
Case "2" ; WORD
PokeW(*buffer2+offset,peekWord(*buffer1+offset))
offset=offset+2
Case "4" ; LONG
PokeL(*buffer2+offset,PeekLong(*buffer1+offset))
offset=offset+4
Case "1" ; BYTE
PokeB(*buffer2+offset,PeekByte(*buffer1+offset))
offset=offset+1
EndSelect
Next
ProcedureReturn(offset)
EndProcedure
pas exactementDobro a écrit :c'est simpleThyphoon a écrit : Est ce quelqu'un a l'explication...cela viens de la façon dont sont encodé les octets !!
entre Motorola et intel il y a une inversion entre l'octet de poid fort et de poids faible !!
sur un amiga ou un atari (format motorola ) 03 F3
sur un pc( format intel ) F3 03
explication sur les format "big-endian "
http://fr.wikipedia.org/wiki/Petit-boutiste
il te suffit de lire les octets par 2 (couple) et de swapper a chaque couple
Thyphoon a écrit :@case : Je viens d'essayer ton code ! Chapeau bas car tu as réussi a faire quelques choses alors que moi j'ai même pas réussi a avoir quelques choses de fonctionnel.
J'ai essayé plusieurs icons. Sur certain icon ça plante (entre autre les icons de repertoire)
Mais sinon c'est génial... faut que j'épluche un peu ... En tout cas encore une fois Bravo !!