Page 1 of 1
[TI-ASM] GetCSC hoook
Posted: Sat 17 Mar, 2007 1:27 am
by LolBbq
I'm trying to make the GetCSC hook record a keypress if a keypress is detected, but exit if no keypress is detected. It may seem easy, but I think it's a bit harder than it seems. Once in A=$1b mode, a ld a,b and then or a can easily determine whether there was a keypress. However, such code makes the cursor flash repeatedly (it sort of becomes grayscale-esque). Any suggestions?
Posted: Sat 17 Mar, 2007 5:03 am
by Dwedit
Try not destroying any registers!
Posted: Sat 17 Mar, 2007 7:31 am
by King Harold
this page says: "Return with NZ set"
which does not make any sense to me, NZ means that the Z flag is NOT set, so NZ is never set.
I'd try returning Z and see what happens..
Posted: Sat 17 Mar, 2007 12:05 pm
by LolBbq
Code: Select all
GetCSCHook:
.db $83
cp $1b
ret nz
di
exx
ld a,(Counter-$9d95+AppBackUpScreen)
or a
jp m,SetNormalKey-$9d95+AppBackUpScreen
dec a
ld (Counter-$9d95+AppBackUpScreen),a
ld h,0
ld l,a
ld de,OrderOfKeys-$9d95+AppBackUpScreen
add hl,de
ld a,(hl)
or a
exx
ei
ret
SetNormalKey:
ld a,b
or a
jr z,NoKeyPressed
exx
ei
ret
NoKeyPressed:
xor a
exx
ei
ret
Counter:
.db 10
OrderOfKeys:
.db sk5,sk3,sk5,sk6,sk2,sk9,sk5,sk4,sk1,skDecPnt,sk3
EndGetCSCHook:
At least it doesn't cause the cursor to flash, but now it just displays an 'E' and stops.
Posted: Sat 17 Mar, 2007 1:25 pm
by King Harold
why do you move that OrderOfKeys to appbackup? did you know $9d95 has nothing to do with it? it is for programs and hooks do not run well from programs (theoretically they could.. but don't.).
Posted: Sat 17 Mar, 2007 5:14 pm
by LolBbq
This is why:
Code: Select all
ld hl,AppBackUpScreen
in a,(6)
bcall($4f7b)
Posted: Sat 17 Mar, 2007 8:33 pm
by King Harold
that is going to annoy you, because it will be swapped in at $4000 afaik, so you'll have to relocate to $4000 + (appbackup-$8000) + offeset which is (appbackup - $4000) + offset
Posted: Mon 19 Mar, 2007 8:49 pm
by King Harold
forgot to mention you'll have to IN A,(7)..
and you'll crash the calc if something overwrites the hook someway halfway in it and leaves the $83 so it will be a "valid" hook..