nesdev.comhttp://forums.nesdev.com/ 8x16 and whatever else unreg wants to knowhttp://forums.nesdev.com/viewtopic.php?f=10&t=7451 Page 89 of 97

 Author: unregistered [ Mon Mar 20, 2017 2:09 pm ] Post subject: Re: 8x16 and whatever else unreg wants to know lidnariq wrote:Branches can go between 129 bytes forward and 126 bytes backwards, and 197 bytes forward is out of range.Ah ok, thanks lidnariq!! Why is it limited to 129 bytes forward? It uses positive and negative numbers maybe... so oh ok, windows 10 calculator in programmer's mode is fantastic!! So if... how does that work? How does it differentiate between forwards and backwards? Well, it must use positive and negative numbers... I remember it using negative numbers when it went backwards. But 129 is 1000 0001 and 126 is 0111 1110... but it's confusing to me beyond the fact that those two numbers are inverses. Help? *NVM tepples answered! tepples wrote:That's 129 bytes forward or 126 bytes backward from the address of the branch instruction's opcode. The apparent imbalance is because the offset is actually measured from the address of the opcode that would be executed if the branch were not taken, and it has the typical range of an 8-bit signed integer: 127 bytes forward or 128 bytes backward.Thank you so much tepples!! Makes sense! ---found Loopy's new site (from Memblers) (through google): http://3dscapture.com/NES/

 Author: unregistered [ Sun May 28, 2017 4:33 pm ] Post subject: Re: 8x16 and whatever else unreg wants to know I'm trying to get a new screen to load when our lady reaches the top of the screen (oY == 00). Almost everything works; as soon as oY reaches 00, currFloor is decremented and stairs is jsred. Stairs tries to disable vblank by anding my copy of \$2000 with #01111111b. Then see is jsred correctly.The only problem is that see never finishes because a vblank is activated and see is called again... the hex editor shows the stack is constantly decremented because see keeps being run because vblanks keep being called.My function see sets up the screens before the game starts. It works wonderfully. Do you have any advice for me to turn off vblanks successfully? I have found where the wiki advises reading \$2002 before turning on bit 7 of \$2000, but I`m trying to turn bit 7 of \$2000 off.

 Author: tokumaru [ Sun May 28, 2017 6:55 pm ] Post subject: Re: 8x16 and whatever else unreg wants to know I'm of the opinion that it's better to leave NMIs always on and control what happens each vblank entirely in software. You can even use the shadow \$2001 register to detect when rendering is off, in which case the vblank handler skips all code related to the PPU (after updating register \$2001 with the shadow value, that is), so it doesn't interfere with any PPU operations the main thread may be doing (e.g. large updates between levels), but still updates the APU so that music and sound effects aren't interrupted by screen transitions.

 Author: unregistered [ Sun May 28, 2017 10:09 pm ] Post subject: Re: 8x16 and whatever else unreg wants to know That's brilliant tokumaru!! Will definitely try using shadow \$2001; I didn't even consider the music needing vblank updates. Thank you!

 Author: tokumaru [ Mon May 29, 2017 12:10 am ] Post subject: Re: 8x16 and whatever else unreg wants to know If you wanted to disable rendering for a big update using this method, you'd first change the \$2001 shadow value, and then wait for vblank (using whatever communication system you have between the main thread and the NMI thread), when \$2001 will effectively be written to and rendering will be disabled. From then on you can update VRAM freely (keep in mind that palette and OAM updates should only take place during vblank, to completely avoid colorful glitches and OAM corruption), because the NMI thread will know not to do any PPU operations other than copying the shadow \$2001 value to register \$2001, a write that should be harmless even if it interrupts other PPU operations the main thread might be doing.

 Author: unregistered [ Wed May 31, 2017 10:48 am ] Post subject: Re: 8x16 and whatever else unreg wants to know So I need to wait for NMI so soft2001shadow can be copied to \$2001 because then rendering will be disabled. And that will help me to be able to run see in the main thread! That`s so cool! Is it ok to just set \$2001 each vblank without checking first to see if I can? All the pointless cycles wasted; it makes me so happy to not waste cycles. Thank you tokumaru for all of your wisdom you share.

 Author: tepples [ Wed May 31, 2017 11:42 am ] Post subject: Re: 8x16 and whatever else unreg wants to know Rewriting \$2001 in every vblank is perfectly fine. So is \$2000 as long as the main thread isn't in the middle of a bulk upload.

 Author: tokumaru [ Wed May 31, 2017 11:46 am ] Post subject: Re: 8x16 and whatever else unreg wants to know unregistered wrote:Is it ok to just set \$2001 each vblank without checking first to see if I can?As far as I know, yes. Writing to \$2001 shouldn't have any undesirable side effects, even if it happens in the middle of other PPU operations. But you do need to test whether rendering is on or off to decide whether to do other potentially dangerous PPU operations (updating VRAM, setting the scroll, etc.). Your NMI handler could contain something like this:Code:   lda PPUMaskShadow   sta \$2001   and \$%00011000   beq PPUStuffDone   ;(PPU updates here)PPUStuffDone:   ;(APU and other mandatory updates here)

 Author: unregistered [ Wed May 31, 2017 5:19 pm ] Post subject: Re: 8x16 and whatever else unreg wants to know Just wanted to quickly say that your helpful advice made the screen appear. It's not the correct screen, but it is a screen! Tons better than the black screen. Thank you tokumaru so much!! Have to go make supper; thanks tepples for confirming that 2001 can be assigned every frame. Thank you all so very much!