Skip to content

Commit e8b9506

Browse files
committed
sizing things up in the window
Signed-off-by: Ronald G. Minnich <[email protected]>
1 parent b1991e3 commit e8b9506

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/visitors/display.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ func (v *Display) Visit(f uefi.Firmware) error {
5656

5757
b := bytes.NewBuffer(f.Buf())
5858
os.WriteFile(v.Name, f.Buf(), 0644)
59-
// The display is 256KiB x however many rows we need.
59+
numblocks := b.Len()/uefi.RegionBlockSize
60+
// The display is 256 blocks x however many rows we need.
6061
// So that's len(buf) / (256x1024)
61-
squareSize := 1
62-
wid := 100 + 256*squareSize
63-
ht := 100 + squareSize*b.Len()/(wid*1024)
62+
squareSize := 2
63+
wid := 256*squareSize
64+
ht := squareSize*(numblocks/256)
6465
// Initialize the draw context with a dynamically-sized window
65-
d, err := draw.Init(nil, "", v.Name, fmt.Sprintf("256x%d", ht))
66+
d, err := draw.Init(nil, "", v.Name, fmt.Sprintf("%dx%d", wid+50, ht+20))
6667
if err != nil {
6768
return fmt.Errorf("failed to initialize draw: %w", err)
6869
}
@@ -86,7 +87,7 @@ func (v *Display) Visit(f uefi.Firmware) error {
8687
for y := 0; y < winHeight; y++ {
8788
for x := 0; x < winWidth; x++ {
8889
// Calculate the top-left corner of the square
89-
pt := draw.Pt(50+x*squareSize, 50+y*squareSize)
90+
pt := draw.Pt(20+x*squareSize, 20+y*squareSize)
9091
rect := draw.Rect(pt.X, pt.Y, pt.X+squareSize, pt.Y+squareSize)
9192
n, err := b.Read(buf[:])
9293
if err != nil && err != io.EOF {

0 commit comments

Comments
 (0)