From a837148c3b29157ec6877b9c45318e50880832b9 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Sat, 7 Apr 2018 11:42:00 +0100 Subject: [PATCH] Add support in klogo for abnormal headers, try to improve logo --- code/apps/app-klogo.lua | 21 +++++++++++++++------ code/data/app-klogo/logo.bmp | Bin 1530 -> 1462 bytes 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/code/apps/app-klogo.lua b/code/apps/app-klogo.lua index 3153beb..418d82b 100644 --- a/code/apps/app-klogo.lua +++ b/code/apps/app-klogo.lua @@ -6,11 +6,13 @@ local neoux = require("neoux")(event, neo) local braille = require("braille") local bmp = require("bmp") local icecap = neo.requireAccess("x.neo.pub.base", "loadimg") -local qt = icecap.open("/logo.bmp", false) +local file = icecap.open("/logo.bmp", false) -local header = qt.read(bmp.headerMinSzBMP) +local header = file.read(bmp.headerMinSzBMP) +local palette = "" local lcBase = bmp.headerMinSzBMP +local palBase = bmp.headerMinSzBMP local lcWidth = 1 local lc = {} @@ -25,17 +27,23 @@ end local function getLine(y) if not lc[y] then local idx = y * lcWidth - qt.seek("set", lcBase + idx - 1) + file.seek("set", lcBase + idx - 1) if lcdq[1] then lc[table.remove(lcdq, 1)] = nil end table.insert(lcdq, y) - lc[y] = qt.read(lcWidth) + lc[y] = file.read(lcWidth) end return lc[y] end local bitmap = bmp.connect(function (i) + if i >= palBase then + local v = palette:byte(i + 1 - palBase) + if v then + return v + end + end if i >= lcBase then local ld = getLine(math.floor((i - lcBase) / lcWidth)) i = ((i - lcBase) % lcWidth) + 1 @@ -44,8 +52,9 @@ local bitmap = bmp.connect(function (i) return header:byte(i) or 0 end) -qt.seek("set", bitmap.paletteAddress - 1) -header = header .. qt.read(bitmap.paletteCol * 4) +file.seek("set", bitmap.paletteAddress - 1) +palette = file.read(bitmap.paletteCol * 4) +palBase = bitmap.paletteAddress lcBase = bitmap.dataAddress lcWidth = bitmap.dsSpan diff --git a/code/data/app-klogo/logo.bmp b/code/data/app-klogo/logo.bmp index b926433db887335de52e9652239c3ff0fed80c61..f9c28b9ff76d28eaaf10f620df299ed87e0fbcfb 100644 GIT binary patch delta 483 zcmZ{gJqm+B5QPV0swq4|z$Phjh)uAQ+#+X4k;W^;CLrVx3lW>?(gnPO_Xr4iJDL@Z zE;y|7&CkB~;fkZ zxs+o(!(85t6%%AdaSKO{Mj=urc)TYJ2#w0>ddx}+yM^eRGDGPS%PA`Q z8HK$EkfEiFhuoP4XO%9?PSq`KJi2nlt1JlfzGbccd0_%gw0WAUY>Y2`*IfE?8 zzz^04b^|UskXdMQ9~gjc06P?q9LQg2`s%@62L%AwrKpa9%0Ydhq@;x8P_Tc%7J_UB m1EA?hK>(2h`UY7JY!NWXA!0x!Y(N&!?#cd4@|(?=8khkNC!Zq#