9Fermer11
deephLe 27/11/2012 à 00:29
Bon j'étais partit pour tester les sprites, mais je n'ai pas trouvé d'outil me convenant donc j'ai décidé d'en faire un avec PureBasic smile

Je ne suis pas sûr qu'il fonctionne correctement (pas eut le temps de tester, et là je commence à... zzz) : img2asm.zip

Il gère les images 5-bits (16 couleurs), enfin en théorie smile

Le code source :
EnableExplicit
If OpenConsole() = 0
  MessageRequester("OpenConsole() error","Unable to open the console.",0)
  End
EndIf
Define i.l
Global str1$
For i = 1 To 17
  str1$ = str1$ + Chr(205)
Next
ConsoleTitle ("img2asm")
EnableGraphicalConsole(1)
PrintN(Chr(201)+str1$+Chr(187))
PrintN(Chr(186)+" img2asm - deeph "+Chr(186))
PrintN(Chr(200)+str1$+Chr(188))
PrintN("")
If CountProgramParameters() > 0
  Define file.s = ProgramParameter()
  If GetExtensionPart(file) = "jpg" Or GetExtensionPart(file) = "jpeg"
    UseJPEG2000ImageDecoder()
  ElseIf GetExtensionPart(file) = "png"
    UsePNGImageDecoder()
  ElseIf GetExtensionPart(file) = "tif"
    UseTIFFImageDecoder()
  ElseIf GetExtensionPart(file) = "tga"
    UseTGAImageDecoder()
  ElseIf GetExtensionPart(file) <> "bmp"
    PrintN("Error : image format unsupported.")
    Input()
    End
  EndIf
  If LoadImage(0, file)
    If ImageDepth(0, #PB_Image_OriginalDepth) <> 5
      If CreateFile(0, GetPathPart(ProgramFilename())+ReplaceString(GetFilePart(file), GetExtensionPart(file), "asm"))
        If StartDrawing(ImageOutput(0))
          WriteStringN(0, ReplaceString(GetFilePart(file), "."+GetExtensionPart(file), "")+":")
          WriteString(0, Chr(9)+"dcw ")
          Define y.l, x.l, i.l = 0
          For y = 0 To ImageHeight(0)-1
            For x = 0 To ImageWidth(0)-1
              If i=8
                WriteStringN(0, "")
                WriteString(0, Chr(9)+"dcw ")
                i=0
              ElseIf i>0
                WriteString(0, ",")
              EndIf
              i+1
              WriteString(0, "0x"+RSet(Hex(Int(Red(Point(x, y))/8)+Int(Green(Point(x, y))/8)<<5+Int(Blue(Point(x, y))/8)<<10), 4, "0")) ; (r)+(g<<5)+(b<<10)
            Next x
          Next y
          WriteStringN(0, "")
          StopDrawing()
        EndIf
        PrintN(ReplaceString(GetFilePart(file), GetExtensionPart(file), "asm")+" correctly generated.")
        CloseFile(0)
      Else
        PrintN("Error : unable to create the output file.")
      EndIf
    Else
      PrintN("Error : incorrect image depth (use 16 colors).")
    EndIf
  Else
    PrintN("Error : unable to open the image.")
  EndIf
Else
  PrintN("Error : no input.")
EndIf
End

Ah aussi, j'ai trouvé pas mal d'info ici : http://www.loirak.com/gameboy/gbatutor.php