more tests
This commit is contained in:
parent
3263ced845
commit
2361c82432
@ -30,6 +30,10 @@ cdgPlayer.tempdata={
|
|||||||
colors={},
|
colors={},
|
||||||
index=1,
|
index=1,
|
||||||
data={},
|
data={},
|
||||||
|
frames=0,
|
||||||
|
getFrames=function(self)
|
||||||
|
return self.frames
|
||||||
|
end,
|
||||||
next=function(self)
|
next=function(self)
|
||||||
local data=self.data[self.index]
|
local data=self.data[self.index]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
@ -41,19 +45,30 @@ function cdgPlayer:packCommand(cmd,...)
|
|||||||
--~ print("Packing: "..cmd)
|
--~ print("Packing: "..cmd)
|
||||||
table.insert(self.tempdata.data,{cmd,...})
|
table.insert(self.tempdata.data,{cmd,...})
|
||||||
end
|
end
|
||||||
function cdgPlayer:init(cdgFileName)
|
function cdgPlayer:dump(...)
|
||||||
|
if self.dumpit then
|
||||||
|
print(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function cdgPlayer:init(cdgFileName,dump)
|
||||||
|
self.dumpit=dump
|
||||||
self.FileName = cdgFileName
|
self.FileName = cdgFileName
|
||||||
-- Check the CDG file exists
|
-- Check the CDG file exists
|
||||||
if not love.filesystem.exists(self.FileName) then
|
if not love.filesystem.exists(self.FileName) then
|
||||||
ErrorString = "No such file: ".. self.FileName
|
ErrorString = "No such file: ".. self.FileName
|
||||||
error(ErrorString)
|
error(ErrorString)
|
||||||
end
|
end
|
||||||
|
--~ if not io.fileExists(self.FileName) then
|
||||||
|
--~ ErrorString = "No such file: ".. self.FileName
|
||||||
|
--~ error(ErrorString)
|
||||||
|
--~ end
|
||||||
self:decode()
|
self:decode()
|
||||||
return self.tempdata
|
return self.tempdata
|
||||||
end
|
end
|
||||||
function cdgPlayer:decode()
|
function cdgPlayer:decode()
|
||||||
-- Open the cdg file
|
-- Open the cdg file
|
||||||
self.cdgFile = bin.new((love.filesystem.read(self.FileName)))
|
self.cdgFile = bin.new((love.filesystem.read(self.FileName)))
|
||||||
|
--~ self.cdgFile = bin.load(self.FileName)
|
||||||
-- Main processing loop
|
-- Main processing loop
|
||||||
while true do
|
while true do
|
||||||
packd = self:cdgGetNextPacket()
|
packd = self:cdgGetNextPacket()
|
||||||
@ -114,14 +129,15 @@ end
|
|||||||
function cdgPlayer:cdgMemoryPreset(packd)
|
function cdgPlayer:cdgMemoryPreset(packd)
|
||||||
colour = bit.band(packd['data'][1], 0x0F)
|
colour = bit.band(packd['data'][1], 0x0F)
|
||||||
repea = bit.band(packd['data'][2], 0x0F)
|
repea = bit.band(packd['data'][2], 0x0F)
|
||||||
--~ print (string.format("cdgMemoryPreset [Colour=%d, Repeat=%d]", colour, repea))
|
self:dump(string.format("cdgMemoryPreset [Colour=%d, Repeat=%d]", colour, repea))
|
||||||
self:packCommand("MEMORY_PRESET",colour, repea)
|
self:packCommand("MEMORY_PRESET",colour, repea)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
function cdgPlayer:cdgBorderPreset(packd)
|
function cdgPlayer:cdgBorderPreset(packd)
|
||||||
colour = bit.band(packd['data'][1], 0x0F)
|
colour = bit.band(packd['data'][1], 0x0F)
|
||||||
--~ print (string.format("cdgMemoryPreset [Colour=%d]", colour))
|
self:dump(string.format("cdgMemoryPreset [Colour=%d]", colour))
|
||||||
self:packCommand("MEMORY_PRESET",colour)
|
self:packCommand("MEMORY_PRESET",colour)
|
||||||
|
self.tempdata.frames=self.tempdata.frames+1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
function cdgPlayer:cdgScrollPreset(packd)
|
function cdgPlayer:cdgScrollPreset(packd)
|
||||||
@ -148,7 +164,7 @@ function cdgPlayer:cdgScrollCommon(packd, copy)
|
|||||||
else
|
else
|
||||||
typeStr = "SCROLL_PRESET"
|
typeStr = "SCROLL_PRESET"
|
||||||
end
|
end
|
||||||
--~ print(string.format("%s [colour=%d, hScroll=%d, vScroll=%d]", typeStr, colour, hScroll, vScroll))
|
self:dump(string.format("%s [colour=%d, hScroll=%d, vScroll=%d]", typeStr, colour, hScroll, vScroll))
|
||||||
self:packCommand(typeStr, colour, hScroll, vScroll)
|
self:packCommand(typeStr, colour, hScroll, vScroll)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -178,30 +194,30 @@ function cdgPlayer:cdgTileBlockCommon(packd, xor)
|
|||||||
else
|
else
|
||||||
typeStr = "TILE_BLOCK"
|
typeStr = "TILE_BLOCK"
|
||||||
end
|
end
|
||||||
--~ print(string.format("%s [Colour0=%d, Colour1=%d, ColIndex=%d, RowIndex=%d]", typeStr, colour0, colour1, column_index, row_index))
|
self:dump(string.format("%s [Colour0=%d, Colour1=%d, ColIndex=%d, RowIndex=%d]", typeStr, colour0, colour1, column_index, row_index))
|
||||||
self:packCommand(typeStr, colour0, colour1, column_index, row_index, titlepixels)
|
self:packCommand(typeStr, colour0, colour1, column_index, row_index, titlepixels)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
function cdgPlayer:cdgDefineTransparentColour(packd)
|
function cdgPlayer:cdgDefineTransparentColour(packd)
|
||||||
data_block = packd['data']
|
data_block = packd['data']
|
||||||
colour = bit.band(data_block[1], 0x0F)
|
colour = bit.band(data_block[1], 0x0F)
|
||||||
--~ print (string.format("cdgDefineTransparentColour [Colour=%d]", colour))
|
self:dump(string.format("cdgDefineTransparentColour [Colour=%d]", colour))
|
||||||
self:packCommand("DEF_TRANSP_COL",colour)
|
self:packCommand("DEF_TRANSP_COL",colour)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
function cdgPlayer:cdgLoadColourTableCommon (packd, tab)
|
function cdgPlayer:cdgLoadColourTableCommon (packd, tab)
|
||||||
if tab == 0 then
|
if tab == 0 then
|
||||||
colourTableStart = 0
|
colourTableStart = 0
|
||||||
--~ print ("cdgLoadColourTable0..7")
|
self:dump("cdgLoadColourTable0..7")
|
||||||
else
|
else
|
||||||
colourTableStart = 8
|
colourTableStart = 8
|
||||||
--~ print ("cdgLoadColourTable8..15")
|
self:dump("cdgLoadColourTable8..15")
|
||||||
end
|
end
|
||||||
for i=0,7 do
|
for i=0,7 do
|
||||||
colourEntry = bit.lshift(bit.band(packd['data'][(2 * i)+1], CDG_MASK), 8)
|
colourEntry = bit.lshift(bit.band(packd['data'][(2 * i)+1], CDG_MASK), 8)
|
||||||
colourEntry = colourEntry + bit.band(packd['data'][(2 * i) + 2], CDG_MASK)
|
colourEntry = colourEntry + bit.band(packd['data'][(2 * i) + 2], CDG_MASK)
|
||||||
colourEntry = bit.bor(bit.rshift(bit.band(colourEntry, 0x3F00), 2), bit.band(colourEntry, 0x003F))
|
colourEntry = bit.bor(bit.rshift(bit.band(colourEntry, 0x3F00), 2), bit.band(colourEntry, 0x003F))
|
||||||
--~ print (string.format(" Colour %d = 0x%X", (i + colourTableStart), colourEntry))
|
self:dump(string.format(" Colour %d = 0x%X", (i + colourTableStart), colourEntry))
|
||||||
self.tempdata.colors[#self.tempdata.colors+1]=colourEntry
|
self.tempdata.colors[#self.tempdata.colors+1]=colourEntry
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|||||||
@ -3,15 +3,15 @@ function love.conf(t)
|
|||||||
t.version = "0.10.2" -- The LOVE version this game was made for (string)
|
t.version = "0.10.2" -- The LOVE version this game was made for (string)
|
||||||
t.console = true -- Attach a console (boolean, Windows only)
|
t.console = true -- Attach a console (boolean, Windows only)
|
||||||
|
|
||||||
t.window.title = "Oh God This is painful" -- The window title (string)
|
t.window.title = "Sing" -- The window title (string)
|
||||||
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
||||||
t.window.width = 800 -- The window width (number)
|
t.window.width = 300*3 -- The window width (number)
|
||||||
t.window.height = 800 -- The window height (number)
|
t.window.height = 216*3 -- The window height (number)
|
||||||
t.window.borderless = false -- Remove all border visuals from the window (boolean)
|
t.window.borderless = false -- Remove all border visuals from the window (boolean)
|
||||||
t.window.resizable = false -- Let the window be user-resizable (boolean)
|
t.window.resizable = false -- Let the window be user-resizable (boolean)
|
||||||
t.window.minwidth = 1 -- Minimum window width if the window is resizable (number)
|
t.window.minwidth = 1 -- Minimum window width if the window is resizable (number)
|
||||||
t.window.minheight = 1 -- Minimum window height if the window is resizable (number)
|
t.window.minheight = 1 -- Minimum window height if the window is resizable (number)
|
||||||
t.window.fullscreen = false -- Enable fullscreen (boolean)
|
t.window.fullscreen = true -- Enable fullscreen (boolean)
|
||||||
t.window.fullscreentype = "desktop" -- Standard fullscreen or desktop fullscreen mode (string)
|
t.window.fullscreentype = "desktop" -- Standard fullscreen or desktop fullscreen mode (string)
|
||||||
t.window.vsync = false -- Enable vertical sync (boolean)
|
t.window.vsync = false -- Enable vertical sync (boolean)
|
||||||
t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number)
|
t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number)
|
||||||
|
|||||||
@ -26,18 +26,21 @@ function RGBToHEX(r,g,b)
|
|||||||
HEX[1]=L[(r*15)/255];HEX[2]=L[(g*15)/255];HEX[3]=L[(b*15)/255]
|
HEX[1]=L[(r*15)/255];HEX[2]=L[(g*15)/255];HEX[3]=L[(b*15)/255]
|
||||||
return table.concat(HEX)
|
return table.concat(HEX)
|
||||||
end
|
end
|
||||||
music=love.audio.newSource("test2.mp3", "stream")
|
music=love.audio.newSource("test3.mp3", "stream")
|
||||||
player=cdgPlayer:init("test2.cdg")
|
player=cdgPlayer:init("test3.cdg")
|
||||||
COLORS={}
|
COLORS={}
|
||||||
print(#player.colors)
|
print("Loading Colors: "..#player.colors)
|
||||||
for i=1,#player.colors do
|
for i=1,#player.colors do
|
||||||
COLORS[i-1]=Color.new(HEX4ToRGB(bin.NumtoHEX(player.colors[i])))
|
COLORS[i-1]=Color.new(HEX4ToRGB(bin.NumtoHEX(player.colors[i])))
|
||||||
print(i-1,COLORS[i-1])
|
print(i-1,COLORS[i-1])
|
||||||
end
|
end
|
||||||
BGCOLOR=0
|
BGCOLOR=0
|
||||||
ImageData=love.image.newImageData(300,216)
|
ImageData=love.image.newImageData(300,216)
|
||||||
|
ImageDataRef=love.image.newImageData(300,216)
|
||||||
Image=love.graphics.newImage(ImageData)
|
Image=love.graphics.newImage(ImageData)
|
||||||
screen=gui:newImageLabel(Image,"SCREEN",0,0,300*2,216*2)
|
screen=gui:newImageLabel(Image,"SCREEN",0,0,300*3,216*3)
|
||||||
|
screen:centerX()
|
||||||
|
screen:centerY()
|
||||||
updateFunc=multi:newFunction(function(mself,self)
|
updateFunc=multi:newFunction(function(mself,self)
|
||||||
local data=player:next()
|
local data=player:next()
|
||||||
if not data then return end
|
if not data then return end
|
||||||
@ -48,6 +51,7 @@ updateFunc=multi:newFunction(function(mself,self)
|
|||||||
for x=0,299 do
|
for x=0,299 do
|
||||||
for y=0,215 do
|
for y=0,215 do
|
||||||
ImageData:setPixel(x, y, r, g, b, 255)
|
ImageData:setPixel(x, y, r, g, b, 255)
|
||||||
|
ImageDataRef:setPixel(x, y,data[1],0,0,0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif cmd=="TILE_BLOCK_XOR" then
|
elseif cmd=="TILE_BLOCK_XOR" then
|
||||||
@ -72,24 +76,26 @@ updateFunc=multi:newFunction(function(mself,self)
|
|||||||
for yy=1,#tile do
|
for yy=1,#tile do
|
||||||
for xx=1,#tile[yy] do
|
for xx=1,#tile[yy] do
|
||||||
--print(tile[yy]:sub(xx,xx))
|
--print(tile[yy]:sub(xx,xx))
|
||||||
local rc,gc,bc=ImageData:getPixel(x+(xx-1), y+(yy-1))
|
local rc=ImageDataRef:getPixel(x+(xx-1), y+(yy-1))
|
||||||
local cc=tonumber(RGBToHEX(rc,gc,bc),16)
|
local r,g,b=0,0,0
|
||||||
|
--~ local cc=tonumber(RGBToHEX(rc,gc,bc),16)
|
||||||
if tile[yy]:sub(xx,xx)=="0" then
|
if tile[yy]:sub(xx,xx)=="0" then
|
||||||
local c1=tonumber(RGBToHEX(r1,g1,b1),16)
|
--~ local c1=tonumber(RGBToHEX(r1,g1,b1),16)
|
||||||
local r, g, b = HEX4ToRGB(bin.NumtoHEX(bit.bxor(cc,c1)))
|
r, g, b = unpack(COLORS[bit.bxor(data[1],rc)])
|
||||||
ImageData:setPixel(x+(xx-1), y+(yy-1), r, g, b, 255)
|
ImageDataRef:setPixel(x+(xx-1), y+(yy-1),data[1],0,0,0)
|
||||||
else
|
else
|
||||||
local c2=tonumber(RGBToHEX(r2,g2,b2),16)
|
--~ local c2=tonumber(RGBToHEX(r2,g2,b2),16)
|
||||||
local r, g, b = HEX4ToRGB(bin.NumtoHEX(bit.bxor(cc,c2)))
|
r, g, b = unpack(COLORS[bit.bxor(data[2],rc)])
|
||||||
|
ImageDataRef:setPixel(x+(xx-1), y+(yy-1),data[2],0,0,0)
|
||||||
|
end
|
||||||
ImageData:setPixel(x+(xx-1), y+(yy-1), r, g, b, 255)
|
ImageData:setPixel(x+(xx-1), y+(yy-1), r, g, b, 255)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
mself:hold(1/90)
|
||||||
mself:hold(.01)
|
|
||||||
end
|
end
|
||||||
-- Update the "Screen"
|
-- Update the "Screen"
|
||||||
self:SetImage(love.graphics.newImage(ImageData))
|
self:SetImage(love.graphics.newImage(ImageData))
|
||||||
print(os.clock())
|
--~ print(os.clock())
|
||||||
end)
|
end)
|
||||||
music:play()
|
music:play()
|
||||||
screen:OnUpdate(updateFunc)
|
screen:OnUpdate(updateFunc)
|
||||||
|
|||||||
4
LoveKaraoke/test.lua
Normal file
4
LoveKaraoke/test.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
require("core.bin")
|
||||||
|
require("cdgreader")
|
||||||
|
player=cdgPlayer:init("test2.cdg")
|
||||||
|
print(player:getFrames())
|
||||||
BIN
LoveKaraoke/test3.cdg
Normal file
BIN
LoveKaraoke/test3.cdg
Normal file
Binary file not shown.
BIN
LoveKaraoke/test3.mp3
Normal file
BIN
LoveKaraoke/test3.mp3
Normal file
Binary file not shown.
BIN
test/Karaoke.exe
Normal file
BIN
test/Karaoke.exe
Normal file
Binary file not shown.
BIN
test/OpenAL32.dll
Normal file
BIN
test/OpenAL32.dll
Normal file
Binary file not shown.
BIN
test/SDL2.dll
Normal file
BIN
test/SDL2.dll
Normal file
Binary file not shown.
BIN
test/love.dll
Normal file
BIN
test/love.dll
Normal file
Binary file not shown.
BIN
test/lua51.dll
Normal file
BIN
test/lua51.dll
Normal file
Binary file not shown.
BIN
test/mpg123.dll
Normal file
BIN
test/mpg123.dll
Normal file
Binary file not shown.
BIN
test/msvcp120.dll
Normal file
BIN
test/msvcp120.dll
Normal file
Binary file not shown.
BIN
test/msvcr120.dll
Normal file
BIN
test/msvcr120.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user