N64: Improved the M64 reader lua script. It now uses the forms.openfile function, and displays some info about the movie. Also improved the handling at the end of the movie
This commit is contained in:
parent
56d5d1ef5a
commit
9694792cfb
|
@ -7,13 +7,71 @@
|
|||
-- If you are trying to convert a M64 into BKM format, you can try pausing the emulator and starting recording a movie, then loading this script and letting it run. Beginning a new movie will clear the saveram for you.
|
||||
|
||||
|
||||
-- Change this filename to be the .m64 file you want to play. Lua will look for the movie file right next to this script unless a directory location is given.
|
||||
local m64_filename = "CHANGE_ME.m64"
|
||||
local m64_filename = forms.openfile(nil,nil,"Mupen Movie Files (*.M64)|*.M64|All Files (*.*)|*.*")
|
||||
|
||||
console.clear()
|
||||
if m64_filename == "" then
|
||||
console.output("No movie selected. Exiting.")
|
||||
return
|
||||
end
|
||||
|
||||
console.output("Opening movie for playback: " .. m64_filename)
|
||||
|
||||
-- Open the file and read past the header data
|
||||
local input_file = assert(io.open(m64_filename, "rb"))
|
||||
local data = input_file:read(0x400)
|
||||
local header = input_file:read(0x400)
|
||||
|
||||
-- Check the file and display some info
|
||||
if string.sub(header,1,3) ~= "M64" or string.byte(header,4) ~= 0x1A then
|
||||
console.output("File signature is not M64\\x1A. This might not be an .m64 movie, but I'll try to play it anyway")
|
||||
end
|
||||
|
||||
function remove_nulls(s)
|
||||
if string.len(s) == 0 then
|
||||
return s
|
||||
end
|
||||
|
||||
local i = 1
|
||||
while string.byte(s,i) ~= 0 and i <= string.len(s) do
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return string.sub(s,1,i-1)
|
||||
end
|
||||
|
||||
local movie_rom_name = string.sub(header,0x0C5,0x0E4)
|
||||
movie_rom_name = remove_nulls(movie_rom_name)
|
||||
console.output("Rom name: " .. movie_rom_name)
|
||||
|
||||
local rerecords = string.byte(header,0x11) + string.byte(header,0x12) * 0x100 + string.byte(header,0x13) * 0x10000 + string.byte(header,0x14) * 0x1000000
|
||||
console.output("# of rerecords: " .. rerecords)
|
||||
|
||||
local rerecords = string.byte(header,0x0D) + string.byte(header,0x0E) * 0x100 + string.byte(header,0x0F) * 0x10000 + string.byte(header,0x10) * 0x1000000
|
||||
console.output("# of frames: " .. rerecords)
|
||||
|
||||
local author_info = string.sub(header,0x223,0x300)
|
||||
author_info = remove_nulls(author_info)
|
||||
console.output("Author: " .. author_info)
|
||||
|
||||
local description = string.sub(header,0x301,0x400)
|
||||
description = remove_nulls(description)
|
||||
console.output("Description: " .. description)
|
||||
|
||||
local video_plugin = string.sub(header,0x123,0x162)
|
||||
video_plugin = remove_nulls(video_plugin)
|
||||
console.output("Video Plugin: " .. video_plugin)
|
||||
|
||||
local audio_plugin = string.sub(header,0x163,0x1A2)
|
||||
audio_plugin = remove_nulls(audio_plugin)
|
||||
console.output("Audio Plugin: " .. audio_plugin)
|
||||
|
||||
local input_plugin = string.sub(header,0x1A3,0x1E2)
|
||||
input_plugin = remove_nulls(input_plugin)
|
||||
console.output("Input Plugin: " .. input_plugin)
|
||||
|
||||
local rsp_plugin = string.sub(header,0x1E3,0x222)
|
||||
rsp_plugin = remove_nulls(rsp_plugin)
|
||||
console.output("RSP Plugin: " .. rsp_plugin)
|
||||
|
||||
-- Flag to note that we've reached the end of the movie
|
||||
local finished = false
|
||||
|
@ -32,8 +90,8 @@ local X
|
|||
local Y
|
||||
-- Reads in the next frame of data from the movie, or sets the finished flag if no frames are left
|
||||
function read_next_frame()
|
||||
data = input_file:read(4)
|
||||
if not data then
|
||||
local data = input_file:read(4)
|
||||
if not data or string.len(data) ~= 4 then
|
||||
finished = true
|
||||
return
|
||||
end
|
||||
|
@ -136,10 +194,10 @@ while true do
|
|||
end
|
||||
|
||||
if finished then
|
||||
console.output("done!")
|
||||
console.output("Movie finished")
|
||||
emu.pause()
|
||||
return
|
||||
end
|
||||
|
||||
emu.frameadvance()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue