Scroll glitches after binding it with button

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Scroll glitches after binding it with button

Post by TeMaToS »

After i use binding the increment of scroll wen character on some position right and right button pressed for all time i see normal scrolling like on screenshot1. But when i release button and press it again i see that some glitches with columns happens. Please help me to solve this problem.
Attachments
2scroll.png
2scroll.png (3.16 KiB) Viewed 4763 times
1scroll.png
1scroll.png (2.7 KiB) Viewed 4763 times
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Scroll glitches after binding it with button

Post by Quietust »

Without seeing the actual code, we can only pretend to speculate what's really going on...
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Re: Scroll glitches after binding it with button

Post by TeMaToS »

Quietust wrote:Without seeing the actual code, we can only pretend to speculate what's really going on...
oh yeh, ok)
here)
Attachments
controller.asm
(54.7 KiB) Downloaded 123 times
User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Re: Scroll glitches after binding it with button

Post by TeMaToS »

I could to take some parts of code but it's most of it. Don't think that i am so lazy pig:)
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: Scroll glitches after binding it with button

Post by mikejmoffitt »

I don't have time to have a look at your whole program and understand it at the moment, but I'm not liking how busy your NMI routine is. One better approach would be to use NMI to set a flag, and in your Forever loop, have it repeatedly check for this flag. If that flag is set, clear it, run a frame of logic, and then go back to waiting for the NMI flag.

Code: Select all

NMI:
    php
    pha

    lda #1
    sta vbl_flag
   
    pla
    plp
    rti

Code: Select all

Forever:
    jsr main_logic
wait_nmi:
    lda vbl_flag
    beq wait_nmi
    lda #0
    sta vbl_flag
    jsr ppu_updates
    jmp Forever
This is just a suggestion for structure, not a singular way to do it.
User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Re: Scroll glitches after binding it with button

Post by TeMaToS »

mikejmoffitt wrote:I don't have time to have a look at your whole program and understand it at the moment, but I'm not liking how busy your NMI routine is. One better approach would be to use NMI to set a flag, and in your Forever loop, have it repeatedly check for this flag. If that flag is set, clear it, run a frame of logic, and then go back to waiting for the NMI flag.

Code: Select all

NMI:
    php
    pha

    lda #1
    sta vbl_flag
   
    pla
    plp
    rti

Code: Select all

Forever:
    jsr main_logic
wait_nmi:
    lda vbl_flag
    beq wait_nmi
    lda #0
    sta vbl_flag
    jsr ppu_updates
    jmp Forever
This is just a suggestion for structure, not a singular way to do it.
Thank you so much man, I realy think that it could be much of work for NMI. Ofcource I don't wanna to waste your time at my begining and I just wanna to have some resourses where i can lern NESASM better. Can you please tell me some of this resourses where you lern NESASM? And other grate resourses like books may be?
My studing was only from lessons by bunnyboy and some web pages of 6502 ASM and they don't cover every needetble information.
I want to know more details of NESASM.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Scroll glitches after binding it with button

Post by FrankenGraphics »

There isn't a wealth of NESASM examples and tutorials relatively to other/the total amount of aterial, but the machine language is the same regardless if you use NESASM, nesicide, asm6, ophis, ca65 and so on, so any nes-specific resource will do. you just need to convert the syntax to NESASM style when trying out and modifying example snippets.

http://wiki.nesdev.com/w/index.php/Programming_guide
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Scroll glitches after binding it with button

Post by Bregalad »

mikejmoffitt wrote:I don't have time to have a look at your whole program and understand it at the moment, but I'm not liking how busy your NMI routine is. One better approach would be to use NMI to set a flag, and in your Forever loop, have it repeatedly check for this flag. If that flag is set, clear it, run a frame of logic, and then go back to waiting for the NMI flag.

[...]

This is just a suggestion for structure, not a singular way to do it.
There is absolutely no requitement NOT having a busy NMI (if you know what you're doing) and your example is poor because you don't have to use php/plp in interrupts, the 6502 does it automatically. It could also do a "inc vbl_flag" so you wouldn't need to have a lda/sta pair here, nor a pha/pla pair.

The 3 approach exists - everything in NMI (as early Nintendo and Konami liked to do it), everything in main (what you're advocating and what Squaresoft liked to do it) and work split between main and NMI threads (what most NES games does, for example Capcom games does that but also later Nintendo games). I do not think any approach is inherently supperior to eachother. So this guy have a problem and you're telling him "you should go with everything in main". However you're not pointing to his problem at all - and invent an entierely new "problem" which isn't even one.

As for the original question, it looks like you are uploading a column of tiles at the wrong place. Be sure to log your VRAM updates.
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: Scroll glitches after binding it with button

Post by mikejmoffitt »

Bregalad wrote:So this guy have a problem and you're telling him "you should go with everything in main". However you're not pointing to his problem at all - and invent an entierely new "problem" which isn't even one.
mikejmoffitt wrote:This is just a suggestion for structure, not a singular way to do it.
User avatar
Alp
Posts: 223
Joined: Mon Oct 06, 2014 12:37 am

Re: Scroll glitches after binding it with button

Post by Alp »

FrankenGraphics wrote:There isn't a wealth of NESASM examples and tutorials relatively to other/the total amount of material.
Actually, there's more than enough NESASM examples. The real problem is that none of it's particularly well-known, or even in English!

...and when it *is* in English-- Pong. Huh. :?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Scroll glitches after binding it with button

Post by tokumaru »

Logic and algorithms shouldn't change much from assembler to assembler, what varies greatly is the ROM organization, the way multiple banks are setup, variable declarations... but even in code written for the same assembler, a lot of that structural stuff can change depending on the coder's style.

One thing that can have a big impact on how assembly code looks is the heavy use of macros. I don't normally use macros for logic and algorithms, just for structuring things (e.g. variable management) and for hardware interactions (e.g. bankswitching), so except for the occasional syntax difference (label scopes, indirection, etc.), the logic I write should be easy to follow.
User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Re: Scroll glitches after binding it with button

Post by TeMaToS »

Alp wrote:
FrankenGraphics wrote:There isn't a wealth of NESASM examples and tutorials relatively to other/the total amount of material.
Actually, there's more than enough NESASM examples. The real problem is that none of it's particularly well-known, or even in English!

...and when it *is* in English-- Pong. Huh. :?
You know, Pong is not side scroller and it don't descripted well enough. For example, i think i perfectly read nerdy nights, but nowere i see how to turn of screen when you must to switch the game state from title screen to game screen. And in the sample of code bannyboy write that you must to do that. May be i am so stuped but i don't see any logical way/poionter in his lessons how to do that. I don't think that it's bad lessons, i thanks him so mutch, but this part realy missed((
User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Re: Scroll glitches after binding it with button

Post by TeMaToS »

tokumaru wrote:Logic and algorithms shouldn't change much from assembler to assembler, what varies greatly is the ROM organization, the way multiple banks are setup, variable declarations... but even in code written for the same assembler, a lot of that structural stuff can change depending on the coder's style.

One thing that can have a big impact on how assembly code looks is the heavy use of macros. I don't normally use macros for logic and algorithms, just for structuring things (e.g. variable management) and for hardware interactions (e.g. bankswitching), so except for the occasional syntax difference (label scopes, indirection, etc.), the logic I write should be easy to follow.
You mean that my code hard to read?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Scroll glitches after binding it with button

Post by tokumaru »

No, I'm saying that you can still learn from code written for assemblers other than the one you use, as long as you're looking for actual game logic ideas and not ROM organization tips.
User avatar
TeMaToS
Posts: 20
Joined: Tue Aug 08, 2017 1:25 pm

Re: Scroll glitches after binding it with button

Post by TeMaToS »

tokumaru wrote:No, I'm saying that you can still learn from code written for assemblers other than the one you use, as long as you're looking for actual game logic ideas and not ROM organization tips.
Yeah, it's grate) I just must to discover forum. But may be someone of you have a .asm file with opensource with full NES sidescrolling game?
Post Reply