Simple Cursor Menu For a SNES MultiCart
Moderator: Moderators
Simple Cursor Menu For a SNES MultiCart
Hi Guys
I made this menu using Byuu Bass
I using BG mode 3 and using a Tile in BG1 as the cursor and the BG
But when i press the Down Button, the cursor go full down or full up when i press up
My question is, how i register 1 press then release and press again?
That is the part of the code
//------------------------------------------------------------------------------------------------
Pos1Loop:
LoadLOVRAM(BLANK, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FA44, 1, 1) // Load Text To VRAM Lo Bytes
WaitNMI() // Wait For Vertical Blank
DownA:
ReadJOY({JOY_DOWN}) // Test DOWN Button
beq StartA // "DOWN" Not Pressed? Branch Down
jmp Pos2Loop
StartA:
ReadJOY({JOY_START}) // Test LEFT Button
beq Pos1Loop // "START" Not Pressed? Branch Down
jml $008000
Pos2Loop:
LoadLOVRAM(BLANK, $FA44, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
WaitNMI() // Wait For Vertical Blank
UpB:
ReadJOY({JOY_UP}) // Test DOWN Button
beq DownB // "DOWN" Not Pressed? Branch Down
jmp Pos1Loop
DownB:
ReadJOY({JOY_DOWN}) // Test DOWN Button
beq StartB // "DOWN" Not Pressed? Branch Down
jmp Pos3Loop
StartB:
ReadJOY({JOY_START}) // Test LEFT Button
beq Pos2Loop // "START" Not Pressed? Branch Down
stz.w REG_CGADD // $2121: CGRAM Address
lda.b #%00011111 // Load Black Colour Lo Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Lo Byte
lda.b #%00000000 // Load Black Colour Hi Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Hi Byte
Pos3Loop:
LoadLOVRAM(BLANK, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FAC4, 1, 1) // Load Text To VRAM Lo Bytes
WaitNMI() // Wait For Vertical Blank
UpC:
ReadJOY({JOY_UP}) // Test DOWN Button
beq StartC // "DOWN" Not Pressed? Branch Down
jmp Pos1Loop
StartC:
ReadJOY({JOY_START}) // Test LEFT Button
beq Pos3Loop // "START" Not Pressed? Branch Down
stz.w REG_CGADD // $2121: CGRAM Address
lda.b #%11100000 // Load Black Colour Lo Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Lo Byte
lda.b #%00000011 // Load Black Colour Hi Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Hi Byte
jmp Pos3Loop
//------------------------------------------------------------------------------------------------
Thanks
I made this menu using Byuu Bass
I using BG mode 3 and using a Tile in BG1 as the cursor and the BG
But when i press the Down Button, the cursor go full down or full up when i press up
My question is, how i register 1 press then release and press again?
That is the part of the code
//------------------------------------------------------------------------------------------------
Pos1Loop:
LoadLOVRAM(BLANK, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FA44, 1, 1) // Load Text To VRAM Lo Bytes
WaitNMI() // Wait For Vertical Blank
DownA:
ReadJOY({JOY_DOWN}) // Test DOWN Button
beq StartA // "DOWN" Not Pressed? Branch Down
jmp Pos2Loop
StartA:
ReadJOY({JOY_START}) // Test LEFT Button
beq Pos1Loop // "START" Not Pressed? Branch Down
jml $008000
Pos2Loop:
LoadLOVRAM(BLANK, $FA44, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
WaitNMI() // Wait For Vertical Blank
UpB:
ReadJOY({JOY_UP}) // Test DOWN Button
beq DownB // "DOWN" Not Pressed? Branch Down
jmp Pos1Loop
DownB:
ReadJOY({JOY_DOWN}) // Test DOWN Button
beq StartB // "DOWN" Not Pressed? Branch Down
jmp Pos3Loop
StartB:
ReadJOY({JOY_START}) // Test LEFT Button
beq Pos2Loop // "START" Not Pressed? Branch Down
stz.w REG_CGADD // $2121: CGRAM Address
lda.b #%00011111 // Load Black Colour Lo Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Lo Byte
lda.b #%00000000 // Load Black Colour Hi Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Hi Byte
Pos3Loop:
LoadLOVRAM(BLANK, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FAC4, 1, 1) // Load Text To VRAM Lo Bytes
WaitNMI() // Wait For Vertical Blank
UpC:
ReadJOY({JOY_UP}) // Test DOWN Button
beq StartC // "DOWN" Not Pressed? Branch Down
jmp Pos1Loop
StartC:
ReadJOY({JOY_START}) // Test LEFT Button
beq Pos3Loop // "START" Not Pressed? Branch Down
stz.w REG_CGADD // $2121: CGRAM Address
lda.b #%11100000 // Load Black Colour Lo Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Lo Byte
lda.b #%00000011 // Load Black Colour Hi Byte
sta.w REG_CGDATA // $2122: CGRAM Data Write Hi Byte
jmp Pos3Loop
//------------------------------------------------------------------------------------------------
Thanks
Re: Simple Cursor Menu For a SNES MultiCart
You have the button status of the current frame, but you also need to keep the button status from the previous frame. Before JOY is updated (but after you've used it for that frame), copy JOY into a new variable like JOY_OLD or something. If you want to detect only the transition into each "new" button press, then in the same frame JOY_UP must be 1 and JOY_UP_OLD must be 0.
Re: Simple Cursor Menu For a SNES MultiCart
I use the "bne" at the begning of each loop to stuck in a loop when the control is pressed
Pos2Loop:
ReadJOY({JOY_DOWN}) // Test DOWN Button
bne Pos2Loop
But seens stuck on the line 2
Pos2Loop:
ReadJOY({JOY_DOWN}) // Test DOWN Button
bne Pos2Loop
But seens stuck on the line 2
Re: Simple Cursor Menu For a SNES MultiCart
Seeing the code helps, but it's incomplete, as ReadJOY appears to be a macro. For now I'll have to make assumptions about what it expands to, but that could lead us down the wrong path.
You need something like:
What I suspect is that ReadJOY doesn't read the controller, instead the controller gets read during the NMI routine (or later in the main loop), and gets saved in RAM. The game logic only works directly with that RAM variable. That's normally how it's done in SNES and NES programs. This test will hang because bne Pos2Loop keeps re-checking a variable that can never change, because it never reaches the actual controller reading.
You need something like:
Code: Select all
lda joy1
and #button_a
beq a_not_pressed
and joy1old
bne a_held
; if we didn't take those branches, it's a new button press
Re: Simple Cursor Menu For a SNES MultiCart
Yes ReadJOY is a macro and sorry for not post the entire code
Here is the code and the macro files
I don't know if the ideia is of the cursors, but i set 3 Loops (one for each line) and a arbitrary stuff to do with star button
Re: Simple Cursor Menu For a SNES MultiCart
What you want to do is have 2 variables for a joypad: one that has the buttons that are currently held down (joypad1_down), and one which says which buttons were pressed on this frame (joypad1_press). Then you can just check the variable tracking presses.
Code: Select all
; Button state was just read into joypad1_press. joypad1_down currently has last frame's button state.
LDA joypad1_press
TAY
EOR joypad1_down
AND joypad1_press
STA joypad1_press
STY joypad1_down
Re: Simple Cursor Menu For a SNES MultiCart
Ok i get the point, but new questions apears
1º: • I know that the buttons register are 2 for the joypad 1, ($4218 and $4219) 16bit
• I know that i have to use REP#$30 to set the A X Y to 16bit mode
• Question is, how can i "LDA" two registers in one A, X or Y
2º: I set like this my variables, is correct?
1º: • I know that the buttons register are 2 for the joypad 1, ($4218 and $4219) 16bit
• I know that i have to use REP#$30 to set the A X Y to 16bit mode
• Question is, how can i "LDA" two registers in one A, X or Y
2º: I set like this my variables, is correct?
Code: Select all
seek(WRAM)
Joypad1_down:
db 0
Joypad1_press:
db 0
Re: Simple Cursor Menu For a SNES MultiCart
Your "down" and "press" variables should both be 16-bit (i.e. probably dw 0), and the above-quoted code should work exactly as-is.Vini Ness wrote: ↑Mon Feb 28, 2022 7:34 am Ok i get the point, but new questions apears
1º: • I know that the buttons register are 2 for the joypad 1, ($4218 and $4219) 16bit
• I know that i have to use REP#$30 to set the A X Y to 16bit mode
• Question is, how can i "LDA" two registers in one A, X or Y
2º: I set like this my variables, is correct?Code: Select all
seek(WRAM) Joypad1_down: db 0 Joypad1_press: db 0
On the NES, they'd only be 8 bits wide (for standard controllers) and the code would be exactly the same.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
P.S. If you don't get this note, let me know and I'll write you another.
Re: Simple Cursor Menu For a SNES MultiCart
Thanks for the reply, i get some info about it too
db = 8 bits
dw = 16 bits
Now about the controls, i coding for the SNES (16bit controllers), i know that i can take the NES (8bit controllers) and use, but i don't know how
But think that i need to take registers $4218 (Joy 1 Lower 8 Bits) and $4219 (Joy 1 higher 8 Bits), but i don't know how to do that
Re: Simple Cursor Menu For a SNES MultiCart
Hi guys, today i make some testes
And try to get a 16bits out of register $4218, and worked ok
I used the BSNES Plus to confirm
i wrote this simple code to test
Now i will try to implement the lines you sugested
Thanks again
And sorry for newbie and simple questions
And try to get a 16bits out of register $4218, and worked ok
I used the BSNES Plus to confirm
i wrote this simple code to test
Code: Select all
loop:
lda.b #%00000001
sta.w REG_NMITIMEN // Enable Joypad NMI Reading Interrupt
rep #$30
lda.w $4218
sta.w Joypad1_down
sep #$30
jmp loop
Thanks again
And sorry for newbie and simple questions
Re: Simple Cursor Menu For a SNES MultiCart
I made it, thanks guys
I created a loop to count $0000 to $1000 at begning of each line loop
I created a loop to count $0000 to $1000 at begning of each line loop
Code: Select all
Pos2Loop:
//WaitNMI() // Wait For Vertical Blank
ldy #$0000
LoopB:
LoadLOVRAM(BLANK, $FAC4, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(BLANK, $FA44, 1, 1) // Load Text To VRAM Lo Bytes
LoadLOVRAM(CURSOR, $FA84, 1, 1) // Load Text To VRAM Lo Bytes
iny
cpy #$1000
bne LoopB
UpB:
ReadJOY({JOY_UP})
beq DownB
jmp Pos1Loop
DownB:
ldx.w $4218
cpx #$0400
bne StartB
jmp Pos3Loop
StartB:
ldx.w $4218
cpx #$1000
bne UpB
stz.w REG_CGADD
lda.b #%00011111
sta.w REG_CGDATA
lda.b #%00000000
sta.w REG_CGDATA
jmp UpB