Ir para conteúdo
  • Cadastre-se

Converter de BASIC para algo que rode no Mac?


Posts Recomendados

Pessoal, tem como converter ou criar um executável que rode no Mac a partir de um código fonte em BASIC?

O código abaixo é de um conversor de AVI para SMF (formato de vídeo que roda no Nintendo DS - especificamente no player Spinal).

Quem tiver alguma dica a respeito ... nós users de DS agradecemos muito!!

AppTitle "Spinal Media Converter v1.0"
Graphics 480,320,0,2


Global fnt=LoadFont("Tahoma",13)
SetFont fnt 
preview=1

uncheck=CreateImage(14,14)
check=CreateImage(14,14)

Dim grey(7)
Dim pal(9,2)

SetBuffer ImageBuffer(uncheck)
VWait()

For t=0 To 7
 Read grey(t)
Next

For y=0 To 13
 For x=0 To 13
  Read col
  Color grey(col),grey(col),grey(col)
  Plot x,y
 Next
Next

SetBuffer ImageBuffer(check)
VWait()

For t=0 To 9
 Read pal(t,0),pal(t,1),pal(t,2)
Next

For y=0 To 13
 For x=0 To 13
  Read col
  Color pal(col,0),pal(col,1),pal(col,2)
  Plot x,y
 Next
Next


Global vid_width=256; Full width
Global vid_height=144; 144 = widescreen 192 = fullscreen
Global vid_framerate=12; always 12fps
Global vid_file$;="luxo_jr.avi"; Input filename
Global vid_quality=10; Output quality (1 to 31)
Global vid_output$="output.smf"; Output file
Global vid_volume = 512; Output volume, 512=100% 1024=200% etc.
why=24

IniFileRead("convert"); Read the ini file

;---------------------------------[ set up the window ]---------------------
SetBuffer FrontBuffer()
ClsColor 240,240,240
Cls
DrawBlock uncheck,272,8

Color 0,0,0
Rect 8,8,260,196,0
Rect 10,10,256,192,1
Color 0,0,0
Text 289,7,"Preview" 
Text 272,32,vid_file$
If vid_height=144 Then a$=" - WideScreen" Else a$=" - FullScreen"
Text 272,56,"Dimentions - 256 x "+vid_height+a$
Text 272,80,"Quality - "+vid_quality
Text 272,104,"Audio volume - "+Int(vid_volume/5.12)+"%"
If vid_height=192 Then why=0

Color 240,240,240
Rect 8,212,464,100,1
Color 200,200,200
Rect 8,212,464,100,0
Color 240,240,240
Line 28,212,100,212
Color 255,255,255
Line 471,213,471,311
Line 9,311,471,311
Color 0,0,0
Text 32,205,"Current Task"
task$="Extracting audio from movie file"
Text 16,220,task$

; create an msdos batch file and execute it to create the indevidual frames
batfile = WriteFile("convert.bat")
bat1$ = "mkdir framedump"
bat2$ = "ffmpeg -i "+vid_file$+" -ac 1 -ar 11025 -y -vol "+vid_volume+" audio.wav"
bat3$ = "ffmpeg >wait1.txt"; create a txt file so we know we're done.
bat4$ = "ffmpeg -i "+vid_file$+" -r "+vid_framerate+" -qscale "+vid_quality+" -s "+vid_width+"x"+vid_height+" framedump\%%d.jpg"
bat5$ = "ffmpeg >wait2.txt"; create a txt file so we know we're done.

WriteLine batfile,bat1$
WriteLine batfile,bat2$
WriteLine batfile,bat3$
WriteLine batfile,bat4$
WriteLine batfile,bat5$
CloseFile(batfile)

filename$ = Chr$(34) + "convert.bat" + Chr$(34)
ExecFile(filename$) 

; main loop
While Not keepgoing
 Delay 2
 If MouseHit(1) And mouseregion(272,8,272+14,8+14) Then preview=1-preview
 If preview=0 Then DrawBlock uncheck,272,8 Else DrawBlock check,272,8

 If FileType("wait1.txt") Then 
  task$="Extracting frames from movie file"
  Text 16,232,task$
 End If
 If FileType("wait2.txt") Then keepgoing=1
Wend


  task$="Combining frames to .smf file"
  Text 16,244,task$

framecount#=1
While FileType("framedump\"+Int(framecount#)+".jpg")
 framecount#=framecount#+1
Wend
 framecount#=framecount#-1; remove the last frame cos it doesn't exist



videofile=WriteFile("video.smf"); the video data (spinal media format)
framestep=framecount#/250; Find out how far appart to set the skip
fs#=1; current frame step
Dim frame_offset(250)
Dim frame_number(250)

x=0
For t=1 To framecount#
 If MouseHit(1) And mouseregion(272,8,272+14,8+14) Then preview=1-preview
 If preview=0 Then DrawBlock uncheck,272,8 Else DrawBlock check,272,8


 a$="framedump/"+t+".jpg"; name of frame image
 size_of_frame = FileSize(a$)
;-------------[ Write frame size ]--------------------
 WriteShort(videofile,size_of_frame)
;-------------[ Copy jpg to video file ]--------------
 infile=ReadFile(a$)
 For s=1 To size_of_frame
  bite=ReadByte(infile)
  WriteByte(videofile,bite)
 Next
 CloseFile(infile)

;Cls
If t Mod 12 =0 And preview=1 Then 
	picture=LoadImage(a$)
	VWait()
	DrawBlock picture,10,10+why
End If
; DeleteFile(a$)

; set skip point
 If t=Int(fs#) Then
  frame_offset(x)=current_offset
  frame_number(x)=t
  x=x+1
  fs#=fs#+Float(framecount#/250)
 End If
 current_offset = current_offset + size_of_frame + 2; update the offset
Next 

CloseFile(videofile)

framefile=WriteFile("frames.smf"); save the frame info to a file
For t=0 To 249
 WriteInt(framefile,frame_offset(t))
Next
For t=0 To 249
 WriteInt(framefile,frame_number(t))
Next

CloseFile(framefile)

  Text 16,256,"Creating .smf header"

;-------------[ Create the file header ]--------------
outfile = WriteFile("header.smf")

 table_offset=FileSize("audio.wav")+14+FileSize("video.smf")

WriteShort(outfile,vid_height)
WriteInt(outfile,framecount#)
WriteInt(outfile,FileSize("audio.wav")+14); 20 is number of bytes in header
WriteInt(outfile,table_offset); offset to frame table (currently not used)
CloseFile(outfile)

;-------------[ Join the header and the data ]--------
DeleteFile("wait.txt"); make sure we CAN wait.
batfile = WriteFile("convert.bat")
; This line will extract the audio from the movie in a format [almost] playable in palib
;bat1$ = "copy /b header.smf + video.smf output.smf"
bat1$ = "copy /b header.smf + audio.wav + video.smf + frames.smf "+Lower(vid_output$)
;bat2$ = "ffmpeg >wait.txt"; create a txt file so we know we're done.
WriteLine batfile,bat1$
;WriteLine batfile,bat2$
WriteLine batfile,"del header.smf"
WriteLine batfile,"del frames.smf"
WriteLine batfile,"del audio.wav"
WriteLine batfile,"del video.smf"
WriteLine batfile,"del wait1.txt"
WriteLine batfile,"del wait2.txt"
;WriteLine batfile,"rmdir framedump /s /q"
WriteLine batfile,"ffmpeg > wait.txt"
CloseFile(batfile)

  Text 16,268,"Deleting temp files"

filename$ = Chr$(34) + "convert.bat" + Chr$(34)
ExecFile(filename$)
While Not FileType("wait.txt")
VWait()
Wend
VWait():VWait():VWait():VWait()

DeleteFile("convert.bat")
If FileType("wait.txt") Then DeleteFile("wait.txt")

  Text 16,280,"Done"

;WaitKey()
End



















;----------------------------------[ data for checkboxes ]---------------------
; palette (grey)
Data 90,148,173,197,222,231,243,255
;checkbox un-checked
Data 6,5,3,3,3,3,3,3,3,3,3,3,5,6
Data 6,2,1,2,2,2,2,2,2,2,2,1,2,6
Data 5,1,4,7,7,7,7,7,7,7,7,4,1,5
Data 5,1,5,6,6,6,6,6,6,6,6,5,1,5
Data 4,1,5,5,5,5,5,5,5,5,5,5,1,4
Data 4,1,4,5,5,5,5,5,5,5,5,4,1,4
Data 4,1,4,4,4,4,4,4,4,4,4,4,1,4
Data 4,2,4,4,4,4,4,4,4,4,4,4,2,4
Data 4,2,5,5,5,5,5,5,5,5,5,5,2,4
Data 3,2,6,6,6,6,6,6,6,6,6,6,2,3
Data 3,2,7,7,7,7,7,7,7,7,7,7,2,3
Data 3,1,5,7,7,7,7,7,7,7,7,5,1,3
Data 5,1,0,0,0,0,0,0,0,0,0,0,1,5
Data 6,4,3,2,2,2,2,2,2,2,2,3,4,6

; palette (color)
Data 23,34,49
Data 68,91,120
Data 73,131,196
Data 125,142,162
Data 125,169,210
Data 135,195,243
Data 181,185,189
Data 162,209,238
Data 200,214,219
Data 255,239,244
;checkbox checked
Data 9,9,6,6,6,6,6,6,6,6,6,1,1,8
Data 9,3,1,1,1,1,1,1,1,1,0,0,3,9
Data 8,1,7,9,9,9,9,9,9,3,0,1,1,8
Data 8,1,5,7,7,7,5,7,4,0,0,4,1,8
Data 8,1,4,1,0,3,5,4,1,0,1,5,1,8
Data 6,1,5,1,0,0,4,3,0,0,4,5,1,6
Data 6,2,2,2,0,0,1,0,0,2,4,2,2,6
Data 6,2,4,4,2,0,0,0,0,4,4,4,2,6
Data 6,2,5,5,5,1,0,0,4,5,5,5,2,6
Data 6,2,5,5,5,7,1,1,7,5,5,5,2,6
Data 6,4,7,7,7,7,5,7,7,7,7,7,4,6
Data 6,3,7,9,9,9,9,9,9,9,9,7,3,6
Data 8,3,1,1,1,1,1,1,1,1,1,1,3,8
Data 9,8,6,6,6,6,6,6,6,6,6,6,8,9


Function MouseRegion(x1,y1,x2,y2)
 x=MouseX()
 y=MouseY()
 doop=0
 If x>=x1 And x<=x2 And y>=y1 And y<=y2 Then doop=1
 Return doop
End Function

; ini file reading

; -----------------------------------------------------------------------------
; Read Ini File
; -----------------------------------------------------------------------------
Function IniFileRead(filename$)
;load the ini file settings into global variables
	ThePath$ = filename + ".ini"
	Local ini = ccLoadFile(ThePath)
	Local l$
	Local flag$
	Local Value$

	While Not Eof(ini)
		l$ = ReadLine(ini)			
		flag$ = Trim$(Upper(ccIniFirstString(l$)))
		Value$ = Trim$(Upper(ccIniLastString(l$)))
		num% = Int(Value)

		Select True
			Case flag$ = "FILENAME"
				vid_file$ = value$				

			Case flag$ = "ASPECT"
				vid_height = 192
				If value$ = "FULL" Then vid_height = 192
				If value$ = "WIDE" Then vid_height = 144
			Case flag$ = "QUALITY"
				vid_quality = value$				
			Case flag$ = "OUTPUT"
				vid_output$ = value$				
			Case flag$ = "VOLUME"
				vid_volume = 5.12 * num%

			Default
		End Select		
	Wend
	CloseFile(ini)
End Function


; -----------------------------------------------------------------------------
; Load a file and show error if not found
; -----------------------------------------------------------------------------
Function ccLoadFile% (ThePath$)
	pointer = ReadFile(ThePath$)
	If Not pointer Then
		RuntimeError ("Error loading file "+ThePath$)
		End
	Else
		Return Pointer	
	  EndIf
End Function

; -----------------------------------------------------------------------------
; IniFirst String (return first part of string up to = sign)
; -----------------------------------------------------------------------------
Function ccIniFirstString$(s$)
;pass in a string, this will only return the first part up to, but not including, the = sign (or end)		
	Return ccFirstStringToSub(s$, "=")
End Function

; -----------------------------------------------------------------------------
; IniLast String (return last part of string from = sign)
; -----------------------------------------------------------------------------
Function ccIniLastString$(s$)
;pass in a string, this will only return the last part from, but not including, the = sign
	Return ccLastStringToSub(s$, "=")
End Function

; -----------------------------------------------------------------------------
; ccWriteIniNumber
; -----------------------------------------------------------------------------
Function ccWriteIniNumber(ini%, flag$, value%)
;use this to write flag=number to an ini file
	WriteLine(ini, Upper(flag)+"="+Str(value)) 
End Function

; -----------------------------------------------------------------------------
; ccWriteIniString
; -----------------------------------------------------------------------------
Function ccWriteIniString(ini%, flag$, value$)
;use this to write flag=string to an ini file
	WriteLine(ini, Upper(flag)+"="+value$) 
End Function

; -----------------------------------------------------------------------------
; First String To Sub (return first part of string up to Substring)
; -----------------------------------------------------------------------------
Function ccFirstStringToSub$(s$, sub$)
;pass in a string, this will only return the first part up to, but not including, the substring (or end)
	pos% = Instr(s$, sub$)
;If pos = 0 then then end of the was reached, so return the whole thing.
	If pos = 0 Then
		Return s$
	Else
		Return Mid(s$, 1, pos-1)
	EndIf
End Function

; -----------------------------------------------------------------------------
; Last String To Sub (return last part of string from substring)
; -----------------------------------------------------------------------------
Function ccLastStringToSub$(s$, sub$)
;pass in a string, this will only return the last part from, but not including, the substring
	pos% = Instr(s$, sub$)
;If pos = 0 then then end of the was reached, so return nothing
	If pos = 0 Then
		Return ""
	Else
		Return Mid(s$, pos + Len(sub$), Len(s$)-pos)
	EndIf
End Function

Link para o comentário
Compartilhar em outros sites

  • 1 mês depois...
  • Respostas 3
  • Criado
  • Última resposta

Top Postadores Neste Tópico

Dias Populares

Top Postadores Neste Tópico

Participe do debate

Você pode postar agora e se registrar depois. Se você tem uma conta, entre agora para postar com ela.

Visitante
Responder este tópico…

×   Você colou conteúdo com formatação.   Remover formatação

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Limpar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.



  • Estatísticas do Fórum

    • Total de Tópicos
      56.5k
    • Total de Posts
      466.1k
×
×
  • Criar Novo...