more tests

This commit is contained in:
Ryan 2017-07-14 22:40:30 -04:00
parent 3263ced845
commit 2361c82432
14 changed files with 53 additions and 27 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)))
--~ 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
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)

4
LoveKaraoke/test.lua Normal file
View File

@ -0,0 +1,4 @@
require("core.bin")
require("cdgreader")
player=cdgPlayer:init("test2.cdg")
print(player:getFrames())

BIN
LoveKaraoke/test3.cdg Normal file

Binary file not shown.

BIN
LoveKaraoke/test3.mp3 Normal file

Binary file not shown.

BIN
test/Karaoke.exe Normal file

Binary file not shown.

BIN
test/OpenAL32.dll Normal file

Binary file not shown.

BIN
test/SDL2.dll Normal file

Binary file not shown.

BIN
test/love.dll Normal file

Binary file not shown.

BIN
test/lua51.dll Normal file

Binary file not shown.

BIN
test/mpg123.dll Normal file

Binary file not shown.

BIN
test/msvcp120.dll Normal file

Binary file not shown.

BIN
test/msvcr120.dll Normal file

Binary file not shown.