It only works within bcall(_GetKey). This is a result of using the GetCSC hook. You probably won't be able to use it in most of your favorite ASM programs.
In the ASM programs in which it does work, it carries the potential to break them if they expect OP1 to remain intact across a bcall(_GetKey)
I'll look into making it work when the edit buffer is open
ld hl, (editCursor)
ld de, (editTop)
or a
sbc hl, de
ld (op6Ext), hl
bcall(_closeEditEqu)
;do stuff
;#########################################
fixEditBuffer:
bcall(_closeEditEqu)
bit 5, (iy + $44)
jr z, notMathPrintEnabled
ld hl, saveSScreen
ld bc, 767
bcall(_memClear)
xor a
ld (menuCurrent), a
bcall(_clrLCDFull)
ld hl, cmdShadow
ld de, cmdShadow+1
ld bc, 127
ld (hl), $20
ldir
bcall(_clrTxtShd)
bcall(_homeUp)
ld hl, $40
bcall(_pullDownChk)
bcall($5125)
set curAble, (iy + curFlags)
res curLock, (iy + curFlags)
ret
notMathPrintEnabled:
bcall(_setupEditCmd)
tryIt:
ld bc, (op6Ext)
ld a, b
or c
jr z, bufferIsZero
ld hl, (editTail)
ld de, (editCursor)
ldir
ld (editTail), hl
ld (editCursor), de
bufferIsZero:
ret
In the ASM programs in which it does work, it carries the potential to break them if they expect OP1 to remain intact across a bcall(_GetKey)
;#########################################
pushOP1:
push af
push bc
push de
push hl
ld hl, -12
add hl, sp
ld sp, hl
ex de, hl
ld hl, 12
add hl, sp
ld bc, 10
ldir
ld hl, op1
ld bc, 12
ldir
pop hl
pop de
pop bc
pop af
ret
;##########################################
popOP1:
push af
push bc
push de
push hl
ld hl, 10
add hl, sp
ld de, op1
ld bc, 12
ldir
ld hl, 10+12-1
add hl, sp
ex de, hl
ld hl, 10-1
add hl, sp
ld bc, 10
lddr
inc de
ex de, hl
ld sp, hl
pop hl
pop de
pop bc
pop af
ret
Thepenguin77, thanks for the code. I've handled the OP1 issue differently, however. Also, before I integrate your code for the homescreen, would it be possible that it work in all contexts where the OS uses an edit buffer, not just the homescreen?
HOWEVER, the code has expanded beyond smallEditRAM, and the mechanism I have used to extend it beyond that requires that you have execution protection disabled for RAM page 0. If it isn't disabled, it might crash your calc. (Personally, I've patched my boot code so I never have to worry about it again, but most people won't do that.) If you can disable the protection yourself, then you'll be fine.