Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ asm/
bin/dumpcard_*.bin
bin/card_verification.log
*.7z
/bin/card_dumps
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PATCH=0
PROGVER=$(MAJOR).$(MINOR).$(PATCH)
PACKNAME=SC2Maker_v$(PROGVER)
GITHASH=$(shell git rev-parse --short HEAD)
MECHAEMU=1
MECHAEMU ?= 1
#------------------------------------------------------------------#
#----------------------- Configuration flags ----------------------#
#------------------------------------------------------------------#
Expand Down
34 changes: 31 additions & 3 deletions bin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,40 @@ for i = 1, #RCP do
RELEVANT_CARDPAGES[RCP[i]] = true
end

function CardIntegrityDraw(statusList, pagesChecked, errcnt)
local COLOR_OK=Color.new(240,240,240)
local COLOR_NG=Color.new(200,0,0)
Screen.clear()
Graphics.drawScaleImage(IMG.background, 0, 0, S.X, S.Y)
Font.ftPrint(FNT[1], S.XM, 60, 8, S.X, S.Y, LNG.VERIFYING_CARD)
Font.ftPrint(FNT[3], S.XM, 80, 8, S.X, S.Y, (LNG.FMT_ERR_PAGEMISMATCHES):format(errcnt))
local maxPages = pagesChecked or #statusList
Graphics.drawRect(100, 100, 512, 256, Color.new(200,200,200, 40))

for i = 0, maxPages - 1 do
local status = statusList[i + 1]
if status ~= nil then
local col = i % 256
local px = 100 + col * 2
local py = 100 + math.floor(i / 256) * 4

local color = status and COLOR_OK or COLOR_NG
Graphics.drawRect(px, py, 2, 4, color)
end
end
Screen.flip()

end

function VerifyConquestCard(port)
PageStatusList = {}
local mismatches = { }
local ret = false
local calchash, localhash
for i = 0, CN.MC_AMMOUNT_OF_PAGES-1, 1 do
local progi = (i * 100) / CN.MC_AMMOUNT_OF_PAGES
if (i%PROG_UPDATE_INTERVAL)==0 then ProgressDisplay(progi, C.SWHITE, LNG.VERIFYING_CARD, ("%.0f%%"):format(progi)) end--
calchash, localhash = Conquest.verify_page(port, 0, i)
if calchash ~= localhash then
PageStatusList[i] = (calchash == localhash)
if not PageStatusList[i] then
local unit = {
page=i;--the page
chash = calchash; --the hash we think is the correct
Expand All @@ -352,7 +377,10 @@ function VerifyConquestCard(port)
if RELEVANT_CARDPAGES[i] == true then unit.critical = true end
table.insert(mismatches, unit);
end
if (i%PROG_UPDATE_INTERVAL)==0 then CardIntegrityDraw(PageStatusList, i, #mismatches) end--
end
CardIntegrityDraw(PageStatusList, CN.MC_AMMOUNT_OF_PAGES-1, #mismatches)
System.sleep(3)
return mismatches
end

Expand Down