Still with PVSneslib, i would like to run with main sprite when right key is pressed twice.
I saw that when you keep button pressed, its state is sometimes reset.
This minimal code reproduce issue :
Code: Select all
//#include <snes.h>
#include "snes/console.h"
#include "snes/interrupt.h"
#include "snes/pad.h"
int main(void)
{
consoleInit();
unsigned short pad0;
//setMode(BG_MODE1,0);
//bgSetDisable(1);
//bgSetDisable(2);
//setScreenOn();
while(true)
{
pad0 = padsCurrent(0);
if (pad0 & KEY_DOWN)
{
consoleNocashMessage("PRESSED\r\n");
}
else
consoleNocashMessage("RELEASED\r\n");
WaitForVBlank();
}
return 0;
}
I checked in pvsneslib how is managed pads and scanPads function which give state for pad0 = padsCurrent(0); is called during VBlank,
Function is wrote in asm and i am not familiar with it :
Code: Select all
;---------------------------------------------------------------------------------
; void scanPads(void)
scanPads:
php
phb
phy
sep #$20 ; change bank address to 0
lda.b #$0
pha
plb
rep #$20 ; copy joy states
ldy pad_keys
sty pad_keysold
ldy pad_keys+2
sty pad_keysold+2
;-: lda REG_SLHV ; wait until past lines 224,225
; lda REG_OPHCT
; cmp #224
; beq -
; cmp #225
; beq -
-: lda REG_HVBJOY ; wait until joypads are ready
lsr
bcs -
lda REG_JOY1L ; read joypad register #1
bit #$0F ; catch non-joypad input
beq + ; (bits 0-3 should be zero)
lda.b #$0
+ sta pad_keys ; store 'current' state
eor pad_keysold ; compute 'down' state from bits that
and pad_keys ; have changed from 0 to 1
sta pad_keysrepeat ;
lda REG_JOY2L ; read joypad register #2
bit #$0F ; catch non-joypad input
beq + ; (bits 0-3 should be zero)
lda.b #$0
+ sta pad_keys+2 ; store 'current' state
eor pad_keysold+2 ; compute 'down' state from bits that
and pad_keys+2 ; have changed from 0 to 1
sta pad_keysrepeat+2 ;
ply
plb
plp
rtl
Can you say me if you think something is wrong or if it doesn't come from this function ?
If you have any other idea that could explain this issue, i will be happy to hear clues

Thanks for your help