From 5fe1dc4fdf42e17786fb826617a8c7b500058980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Izaguirre?= Date: Tue, 13 Feb 2024 12:18:29 +0100 Subject: [PATCH] uint8 params --- cardBuilder.go | 9 +++++++++ cardDan2Controller.go | 4 ++-- cardParallelPrinter.go | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cardBuilder.go b/cardBuilder.go index 085279f..9e32221 100644 --- a/cardBuilder.go +++ b/cardBuilder.go @@ -162,6 +162,15 @@ func paramsGetInt(params map[string]string, name string) (int, error) { return strconv.Atoi(value) } +func paramsGetUInt8(params map[string]string, name string) (uint8, error) { + value, ok := params[name] + if !ok { + return 0, fmt.Errorf("missing parameter %s", name) + } + result, err := strconv.ParseUint(value, 10, 8) + return uint8(result), err +} + // Returns a 1 based array of bools func paramsGetDIPs(params map[string]string, name string, size int) ([]bool, error) { value, ok := params[name] diff --git a/cardDan2Controller.go b/cardDan2Controller.go index 53a33d9..ff43b05 100644 --- a/cardDan2Controller.go +++ b/cardDan2Controller.go @@ -65,14 +65,14 @@ func newCardDan2ControllerBuilder() *cardBuilder { c.slotA = &cardDan2ControllerSlot{} c.slotA.card = &c c.slotA.path = params["slot1"] - num, _ := paramsGetInt(params, "slot1file") + num, _ := paramsGetUInt8(params, "slot1file") c.slotA.fileNo = uint8(num) c.slotA.initializeDrive() c.slotB = &cardDan2ControllerSlot{} c.slotB.card = &c c.slotB.path = params["slot2"] - num, _ = paramsGetInt(params, "slot2file") + num, _ = paramsGetUInt8(params, "slot2file") c.slotB.fileNo = uint8(num) c.slotB.initializeDrive() diff --git a/cardParallelPrinter.go b/cardParallelPrinter.go index 267328e..fca68fb 100644 --- a/cardParallelPrinter.go +++ b/cardParallelPrinter.go @@ -36,12 +36,10 @@ func newCardParallelPrinterBuilder() *cardBuilder { return nil, err } c.file = f - err = c.loadRomFromResource("/Apple II Parallel Printer Interface Card ROM fixed.bin") if err != nil { return nil, err } - return &c, nil }, }