TICALCS.net

Full Version: TI-83+ Interrupt Issue (z80)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I found this site on ticalc.org and thought maybe someone here could help me with a problem I am having.

I am working on a game that utilizes greyscale by swapping two images on the screen really fast, so I made a mode 2 interrupt set to draw the images with a custom function. Everything works great until I get to this code, or other loops similar to it:

Code:
SplashKey_Loop:
ld a,(KeyStAny)
cp 1
jr nz,SplashKey_Loop

If I comment out the ld or if I disable interrupts, nothing bad happens at all. I tried disabling interrupts and calling my interrupt within the loop, and it worked just fine.

Even stranger to me is that it only crashes on my key input loops. Initially I had the key input handling within each loop itself, but that caused this crash in menu (and is what led me to putting key handling into the interrupt to try and fix it and that I decided it would be better so I wouldn't have to repeat it elsewhere that it is needed.) I've trimmed down the code and determined that whenever I do ld with the memory address, it crashes. I know that it isn't crashing because of the address as my interrupt reads/writes to it every time.

I have tried it on TI's FlashSim debugger emulator, but it seems like it doesn't handle IM 2 properly. Because of that, I set some breakpoints at appropriate places and disabled interrupts and manually added PC to the stack and set PC to the interrupt address and it all ran just fine.

If anybody here knows if I totally missed something that everyone should know, has any experience with this or a similar issue or knows of something I could try, I would love to hear from them. Thanks.

First of all, welcome to ticalcs.net!

You may want to try Revolution Software's TI-83 Plus emulator, WabbitEmu. Also, not to detour you from making your own grayscale routines, but you may be interested in this set of grayscale routines (scroll down until you see the link to graylib2.inc).

As for you problem, I'm not sure exactly what's causing it, given the snippet of code you gave me (then again, I haven't programmed in Z80 assembly in quite a while). Would you mind posting your entire source code (I suggest using pastebin)?
I may have figured something out... I had the variables in appBackUpScreen, and I just put it in the program itself. Now it doesn't crash, but it doesn't do anything... I'll try to figure this one out and if I need any more help, I'll post here.
Reference URL's