From 3357a675706b38ab5e8693177c85f09f4771ce67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:25:22 -0300 Subject: [PATCH] visual card integrity check when checking card integrity, the card pages checksum status will be represented on screen --- .gitignore | 1 + Makefile | 2 +- bin/main.lua | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2ea5db2..35cec8c 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ asm/ bin/dumpcard_*.bin bin/card_verification.log *.7z +/bin/card_dumps diff --git a/Makefile b/Makefile index ff66f61..63a50a2 100644 --- a/Makefile +++ b/Makefile @@ -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 ----------------------# #------------------------------------------------------------------# diff --git a/bin/main.lua b/bin/main.lua index 6f86ee2..f9ba4b8 100644 --- a/bin/main.lua +++ b/bin/main.lua @@ -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 @@ -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