As part of the ongoing quest to write some sort of Citadel like game, I have some code which builds a room from sprites, and then a character plotted by interrupt which can move around it, pick up objects, clash against things and move from room to room.
This works fine, but I've noticed an issue whereby the character will suddenly jump for no reason - this is because the keyboard checking routine is picking up the jump key has been pressed.
I modified the routines to display via ORWRCH the keypresses on screen and indeed one of the five keyboard keys that I use is being pressed occasionally - this seems to happen at random times mostly around a minute and sometimes a few seconds.
The keyboard checks for keypresses OSBYTE &81:
Code: Select all
LDY #&FF ; Perform keyboard scan
LDA #&81 ; Select OSBYTE &81
JSR osbyte ; Call OSBYTE to check keyboard
CPX #0
BEQ keynotpressed
LDA keycollector
ORA #1
STA keycollector
Indeed, if I remove the interrupt plotter, the keypresses don't happen.
When the interrupt sprite plotter is called I immediately disable interrupts to plot the character and reenable them when plotting is finished, I've found that if I remove the interrupt disable from this code, the random keypresses don't appear to happen.
I thought it a good idea to disable interrupts when the interrupt character plotter runs... but perhaps it isn't - maybe this has something to do with the keypresses.
I also disable interrupts when drawing a new room - this stops the character being plotted during the drawing process - this seems to work fine.
Can I get some advise on this, does it matter whether interrupts are disabled or enabled during an interrupt?
(I'm not sure why disabling interrupts during an interrupt causes the keypresses - maybe the keypresses are nothing to do with the interrupt...?)
Thanks.