# HG changeset patch # User Laurens Holst # Date 1670005138 -3600 # Fri Dec 02 19:18:58 2022 +0100 # Node ID 7e5269c73f6a912bc702baaff710c92efd155271 # Parent 9180f5688622ecaecf62200dab031ea00e1d411e getslot: Early return when the slot is not expanded. This also keeps the secondary slot bits zero when it is not expanded. Although non-zero bits are fine in terms of having a valid ID, since for unexpanded slots these bits are irrelevant, this makes sure the slot ID is a normalized value. diff --git a/sources/getslot.php b/sources/getslot.php --- a/sources/getslot.php +++ b/sources/getslot.php @@ -53,16 +53,17 @@ ex de,hl ld hl,EXPTBL add hl,bc - ld a,(hl) + ex de,hl + ld a,(de) and 80H or c + ret p ld c,a - inc hl ; move to SLTTBL - inc hl - inc hl - inc hl - ld a,(hl) - ex de,hl + inc de ; move to SLTTBL + inc de + inc de + inc de + ld a,(de) bit 7,h jr z,SecondaryShiftContinue rrca @@ -126,10 +127,11 @@ ex de,hl ld hl,EXPTBL add hl,bc - ld a,(hl) + ex de,hl + ld a,(de) and 80H or c - ld c,a + ret p

In this second part we determine the value for the expanded flag (F bit) @@ -137,14 +139,15 @@ table in system memory. This table consists of 4 bytes, one for each slot, where bit 7 indicates whether the slot is expanded. Because in rare cases bits 0-6 can contain a non-zero value, we and the value with 80H to mask out the -unwanted bits before we insert it into the slot ID.

+unwanted bits before we insert it into the slot ID. If the slot is not expanded, +we stop here.

-
    inc hl  ; move to SLTTBL
-    inc hl
-    inc hl
-    inc hl
-    ld a,(hl)
-    ex de,hl
+
    ld c,a
+    inc de  ; move to SLTTBL
+    inc de
+    inc de
+    inc de
+    ld a,(de)
     bit 7,h
     jr z,SecondaryShiftContinue
     rrca
@@ -181,4 +184,4 @@
 
 
 
-
\ No newline at end of file
+