diff --git a/LoveKaraoke/cdgreader.lua b/LoveKaraoke/cdgreader.lua index 0d18fb5..4fb2f54 100644 --- a/LoveKaraoke/cdgreader.lua +++ b/LoveKaraoke/cdgreader.lua @@ -30,6 +30,10 @@ cdgPlayer.tempdata={ colors={}, index=1, data={}, + frames=0, + getFrames=function(self) + return self.frames + end, next=function(self) local data=self.data[self.index] if not data then return end @@ -41,19 +45,30 @@ function cdgPlayer:packCommand(cmd,...) --~ print("Packing: "..cmd) table.insert(self.tempdata.data,{cmd,...}) 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 -- Check the CDG file exists if not love.filesystem.exists(self.FileName) then ErrorString = "No such file: ".. self.FileName error(ErrorString) end +--~ if not io.fileExists(self.FileName) then +--~ ErrorString = "No such file: ".. self.FileName +--~ error(ErrorString) +--~ end self:decode() return self.tempdata end function cdgPlayer:decode() -- Open the cdg file self.cdgFile = bin.new((love.filesystem.read(self.FileName))) +--~ self.cdgFile = bin.load(self.FileName) -- Main processing loop while true do packd = self:cdgGetNextPacket() @@ -114,14 +129,15 @@ end function cdgPlayer:cdgMemoryPreset(packd) colour = bit.band(packd['data'][1], 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) return end function cdgPlayer:cdgBorderPreset(packd) 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.tempdata.frames=self.tempdata.frames+1 return end function cdgPlayer:cdgScrollPreset(packd) @@ -148,7 +164,7 @@ function cdgPlayer:cdgScrollCommon(packd, copy) else typeStr = "SCROLL_PRESET" 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) return end @@ -178,30 +194,30 @@ function cdgPlayer:cdgTileBlockCommon(packd, xor) else typeStr = "TILE_BLOCK" 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) return end function cdgPlayer:cdgDefineTransparentColour(packd) data_block = packd['data'] 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) return end function cdgPlayer:cdgLoadColourTableCommon (packd, tab) if tab == 0 then colourTableStart = 0 ---~ print ("cdgLoadColourTable0..7") + self:dump("cdgLoadColourTable0..7") else colourTableStart = 8 ---~ print ("cdgLoadColourTable8..15") + self:dump("cdgLoadColourTable8..15") end for i=0,7 do 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 = 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 end return diff --git a/LoveKaraoke/conf.lua b/LoveKaraoke/conf.lua index a87289f..9a6bab4 100644 --- a/LoveKaraoke/conf.lua +++ b/LoveKaraoke/conf.lua @@ -3,15 +3,15 @@ function love.conf(t) t.version = "0.10.2" -- The LOVE version this game was made for (string) 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.width = 800 -- The window width (number) - t.window.height = 800 -- The window height (number) + t.window.width = 300*3 -- The window width (number) + t.window.height = 216*3 -- The window height (number) 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.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.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.vsync = false -- Enable vertical sync (boolean) t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) diff --git a/LoveKaraoke/main.lua b/LoveKaraoke/main.lua index 98855c3..817d4a9 100644 --- a/LoveKaraoke/main.lua +++ b/LoveKaraoke/main.lua @@ -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] return table.concat(HEX) end -music=love.audio.newSource("test2.mp3", "stream") -player=cdgPlayer:init("test2.cdg") +music=love.audio.newSource("test3.mp3", "stream") +player=cdgPlayer:init("test3.cdg") COLORS={} -print(#player.colors) +print("Loading Colors: "..#player.colors) for i=1,#player.colors do COLORS[i-1]=Color.new(HEX4ToRGB(bin.NumtoHEX(player.colors[i]))) print(i-1,COLORS[i-1]) end BGCOLOR=0 ImageData=love.image.newImageData(300,216) +ImageDataRef=love.image.newImageData(300,216) 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) local data=player:next() if not data then return end @@ -48,6 +51,7 @@ updateFunc=multi:newFunction(function(mself,self) for x=0,299 do for y=0,215 do ImageData:setPixel(x, y, r, g, b, 255) + ImageDataRef:setPixel(x, y,data[1],0,0,0) end end elseif cmd=="TILE_BLOCK_XOR" then @@ -72,24 +76,26 @@ updateFunc=multi:newFunction(function(mself,self) for yy=1,#tile do for xx=1,#tile[yy] do --print(tile[yy]:sub(xx,xx)) - local rc,gc,bc=ImageData:getPixel(x+(xx-1), y+(yy-1)) - local cc=tonumber(RGBToHEX(rc,gc,bc),16) + local rc=ImageDataRef:getPixel(x+(xx-1), y+(yy-1)) + local r,g,b=0,0,0 +--~ local cc=tonumber(RGBToHEX(rc,gc,bc),16) if tile[yy]:sub(xx,xx)=="0" then - local c1=tonumber(RGBToHEX(r1,g1,b1),16) - local r, g, b = HEX4ToRGB(bin.NumtoHEX(bit.bxor(cc,c1))) - ImageData:setPixel(x+(xx-1), y+(yy-1), r, g, b, 255) +--~ local c1=tonumber(RGBToHEX(r1,g1,b1),16) + r, g, b = unpack(COLORS[bit.bxor(data[1],rc)]) + ImageDataRef:setPixel(x+(xx-1), y+(yy-1),data[1],0,0,0) else - local c2=tonumber(RGBToHEX(r2,g2,b2),16) - local r, g, b = HEX4ToRGB(bin.NumtoHEX(bit.bxor(cc,c2))) - ImageData:setPixel(x+(xx-1), y+(yy-1), r, g, b, 255) +--~ local c2=tonumber(RGBToHEX(r2,g2,b2),16) + 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) end end - mself:hold(.01) + mself:hold(1/90) end -- Update the "Screen" self:SetImage(love.graphics.newImage(ImageData)) - print(os.clock()) +--~ print(os.clock()) end) music:play() screen:OnUpdate(updateFunc) diff --git a/LoveKaraoke/test.lua b/LoveKaraoke/test.lua new file mode 100644 index 0000000..fc6a98b --- /dev/null +++ b/LoveKaraoke/test.lua @@ -0,0 +1,4 @@ +require("core.bin") +require("cdgreader") +player=cdgPlayer:init("test2.cdg") +print(player:getFrames()) diff --git a/LoveKaraoke/test3.cdg b/LoveKaraoke/test3.cdg new file mode 100644 index 0000000..6d91a40 Binary files /dev/null and b/LoveKaraoke/test3.cdg differ diff --git a/LoveKaraoke/test3.mp3 b/LoveKaraoke/test3.mp3 new file mode 100644 index 0000000..e5b255e Binary files /dev/null and b/LoveKaraoke/test3.mp3 differ diff --git a/test/Karaoke.exe b/test/Karaoke.exe new file mode 100644 index 0000000..cb88a76 Binary files /dev/null and b/test/Karaoke.exe differ diff --git a/test/OpenAL32.dll b/test/OpenAL32.dll new file mode 100644 index 0000000..301355d Binary files /dev/null and b/test/OpenAL32.dll differ diff --git a/test/SDL2.dll b/test/SDL2.dll new file mode 100644 index 0000000..3acfb32 Binary files /dev/null and b/test/SDL2.dll differ diff --git a/test/love.dll b/test/love.dll new file mode 100644 index 0000000..60c1016 Binary files /dev/null and b/test/love.dll differ diff --git a/test/lua51.dll b/test/lua51.dll new file mode 100644 index 0000000..2338fcf Binary files /dev/null and b/test/lua51.dll differ diff --git a/test/mpg123.dll b/test/mpg123.dll new file mode 100644 index 0000000..e93412c Binary files /dev/null and b/test/mpg123.dll differ diff --git a/test/msvcp120.dll b/test/msvcp120.dll new file mode 100644 index 0000000..4ea1efa Binary files /dev/null and b/test/msvcp120.dll differ diff --git a/test/msvcr120.dll b/test/msvcr120.dll new file mode 100644 index 0000000..d711c92 Binary files /dev/null and b/test/msvcr120.dll differ