b102: ld a, (iy+$05) ;first wordThere's also a problem with stack so we need to find two bytes to get the extra POP in. The following patch fixes the problem:
b105: inc a ;move to next word in list
b106: cp $0f ;gone past last word (nefarious)?
b108: call nc, $b110 ;yes
b10b: ld (iy+$05), a ;no, so preserve word and continue
b10e: jr $b0de
b110: ld a, (ix+$06) ;second word <----Here is bug should be ld a, (iy+$06)
b113: inc a ;move to next word in list
b114: cp $07 ;gone past last word (frightmare)?
b116: jr z, $b11d ;yes
b118: ld (iy+$06), a ;no, so preserve second word,
b11b: xor a ;set first word to beginning of list and continue
b11c: ret
;player reaches ultimate dream state (nefarious frightmare)
;in normal game this code never runs due to bug
b11d: ld a, $13 ;length =19 (nefariousfrightmare)
b11f: ld (iy+$07), a
b122: ld a, $06 ;set second word to frightmare
b124: ld (iy+$06), a
b127: ld a, $0e ;set first word to nefarious
b129: ld (iy+$05), a
b12c: ld a, $01 ;disallow any further changes to dream state
b12e: ld ($b0cb), a
;message update
b131: ld de, $5801
b134: ld hl, $5800
b137: ld (hl), $00
b139: ld bc, $003f
b13c: ldir
b13e: call $a6f5
b141: pop ix
b143: ret
org $b110
defb $fd ;fix original bug, iy not ix
org $b0f9
defb $32 ;update normal jump (jp $b132)
org $b11d
dec a ;a=7 at this point so 1 byte saved here
ld (iy+6),a
ld a,$13
ld (iy+7),a
ld a,$0e
ld (iy+5),a
ld a,1
ld ($b0cb),a
pop ix ;now lose 2 bytes to clear stack with extra pop
ld de,$5801
ld hl,$5800
ld (hl),l ;2nd byte saved here
Spectrum Computing acknowledges the rights of copyright holders. If you would like your software removed from our preservation archive and made unavailable for download (or have any queries) please contact spectrumcomputing@outlook.com.