It is currently Mon Nov 20, 2017 2:45 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 53 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Tue Jul 28, 2015 3:38 am 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
Quote:
That's weird, but I'd assume it's because the resulting file isn't a power of two.


I tried uploading my 256 KiB CHR file to it and no matter what I do with that or anything it just seems to crash. Not sure what next.


Top
 Profile  
 
PostPosted: Tue Jul 28, 2015 6:28 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19233
Location: NE Indiana, USA (NTSC)
Have you tried uploading the PRG+CHR from any other MMC3 game, such as the Holy Diver Batman test ROM?

(Also I noticed you haven't corrected the header or cleared the nametable.)


Top
 Profile  
 
PostPosted: Tue Jul 28, 2015 11:41 am 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
tepples wrote:
Have you tried uploading the PRG+CHR from any other MMC3 game, such as the Holy Diver Batman test ROM?

(Also I noticed you haven't corrected the header or cleared the nametable.)


What needs to be corrected about the header, and how/why would I clear the nametable?


Top
 Profile  
 
PostPosted: Tue Jul 28, 2015 11:51 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
raydempsey wrote:
What needs to be corrected about the header?

lidnariq wrote:
The header marks 512 KiB of CHR, but only 256 KiB is present ... nevermind that MMC3 can't address more than 256 KiB.


raydempsey wrote:
how/why would I clear the nametable?

Clear the nametable because its contents are unpredictable at startup on hardware. Kinda surprised that you're asking "how" after successfully making an animated ROM, but here's code anyway:
Code:
clear_nametables:
   lda $2002
   lda #$20
   sta $2006
   lda #$00
   sta $2006 ; PPU latched to $2000
   sta $2000 ; to set PPU address increment to single byte (just in case)
   tax
   tay
   : ; write 4096 zeroes to wipe all nametables
      sta $2007
      inx
      bne :-
      iny
      cpy #16
      bcc :-
   rts

This code presumes that both nametables are presently connected, as in horizontal or vertical mapping. You may need to initialize the mapper's mirroring mode before doing this.


Top
 Profile  
 
PostPosted: Tue Jul 28, 2015 2:32 pm 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
Asking why to clear the nametable was what I wanted to know most. If the reason the nametable needed to be cleared was something particularly ornate, then the "how" part would have been necessary especially if the solution was strange too. Since you meant clearing the nametable as in assigning all the nametable tiles to #$00, then the how was unnecessary. Yes I know how to set nametable locations tiles to #$00. As for my header, this is how I have it (set for NESASM3)
Code:
  .inesmap 4   ; mapper 4 = MMC3
  .inesprg 8   ; # of 8KB PRG banks 64KB
  .ineschr 64  ; # of 4KB CHR banks 256KB
  .inesmir 3   ; background mirroring

First 16 bytes of my .nes file:
4E 45 53 1A 08 40 43 00 00 00 00 00 00 00 00 00

What do each of the values mean? Does $04 mean number of 8 KiB PRG banks as set from .inesprg? Does $05 mean number of 4 KiB or 8 KiB CHR banks as set from .ineschr? Is my .ineschr comment incorrect?


Top
 Profile  
 
PostPosted: Tue Jul 28, 2015 2:40 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6446
Location: UK (temporarily)
raydempsey wrote:
.inesprg 8 ; # of 8KB PRG banks 64KB
.ineschr 64 ; # of 4KB CHR banks 256KB
Whatever gave you those numbers is wrong, the header specifies the # of 16 KiB PRG banks and # of 8 KiB CHR banks.

(Since you seem to have 128 KiB of PRG, 128÷16=8, and 256 KiB of CHR, 256÷8=32)


Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 1:12 am 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
I made a comparison video showing my game Blurred Lines 2048 next to the music video for Blurred Lines. Check it out!

https://www.youtube.com/watch?v=KPS4QvNJrQo


Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 5:55 pm 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
I still can't figure out why I'm getting a stack explosion. As it stands, the stack explosion will happen the moment a player presses start. If you erase the contents under the label ClearNametables: then the stack explosion somehow doesn't happen but I need that in the initial part of my program to clear the name tables. I was told that stack explosions only happen if info is abandoned in the stack from things like PHA and JSR but it doesn't explain why my stack explodes just by including the ClearNametables: label. Erase it and compile, you'll see. I tried running a trace logger in FCEUX but I am too much of a noob to be able to interpret it. You guys would probably be able to spot it very quickly.

I attached the .asm file if anybody can help me figure out how to stop the stack explosion. Once this gets figured out, I am ready to upload it to a cart. Thanks!


Attachments:
BlurredLines2048.nes [384.02 KiB]
Downloaded 57 times
BlurredLines2048.asm [78.05 KiB]
Downloaded 55 times
Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 6:40 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1035
Woah. Single file... that... doesn't use names for the RAM. That... must have been hard to maintain.

You know can actually variable defines, right? Like...

Code:
songTotalPosition = $A0

lda #$82
sta songTotalPosition

You named all your RAM up top, sure. But that doesn't make this easy for someone else to read.

This also isn't the most fun without being able to assemble (since we lack the DMC stuff). Being able to assemble lets us more easily see what labels the addresses in the debugger correspond to.

What eventually ends up happening is that an RTS at $E311 returns to $EB00, where there is no code. Which could mean a JSR was never called before that RTS hit.

The RTS in question is the one below NotZero. I could give this a more in depth look because the problem may be far before NotZero is ever reached. But... is it possible to clean the code up some?

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 6:50 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3484
Location: Indianapolis
Code:
 07:EAF2:A2 00     LDX #$00
 07:EAF4:8E 52 00  STX $0052 = #$00
 07:EAF7:BD 00 00  LDA $0000,X @ $00FF = #$00
 07:EAFA:8D 50 00  STA $0050 = #$00
 07:EAFD:20 9B E2  JSR $E29B
 07:EB00:CA        DEX
 07:EB01:00        BRK
 07:EB02:04        UNDEFINED
 07:EB03:3F        UNDEFINED
 07:EB04:00        BRK
 07:EB05:20 23 C0  JSR $C023
 07:EB08:04        UNDEFINED
 07:EB09:23        UNDEFINED


Looking in the trace logger, with a break point on writes to $0100-$01C0, hits this point. Whatever this subroutine is (I didn't try finding it in the source or assembling it), it's leading the CPU to it's doom.

My guess is something weirder is going on. If you replace the nametable clearing with the same number of NOPs, maybe you would get the same crashing result. It's hard to see how that code PPU init code could be doing anything. In the worst case, it could be one of NESASM's "silent errors". What version of the assembler are you using?

BTW, because NESASM doesn't assume you want to use zeropage (one of the things that annoys me about it), all of your instructions using ZP like STX $52 are actually assembling as STX $0052. This shouldn't have anything to do with your error, but it does make the program bigger and run slower.


Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 6:57 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6446
Location: UK (temporarily)
An unrelated thing: You don't wait long enough before you start uploading things (cleared nametables) to the PPU.

This is usually handled with something like:
Code:
 BIT $2002 ; to ensure that the NMI flag is cleared if the user hit RESET during NMI
l1:
 BIT $2002 ; wait for 241/291 scanlines to pass
 BPL l1
l2:
 BIT $2002 ; wait for another 262/312 scanlines to pass (although we only needed 22)
 BPL l2


Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 8:30 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1035
I mirror Memblers in asking which version of NESASM you're using.

Here's your code:
Code:
UpdateTiles:
  LDX #$00
LoadBlock:
  STX $52
  LDA $00,X
  STA $50
  JSR IndividualTile
  LDX $52
  INX
  CPX #$10
  BNE LoadBlock
  RTS

Here's the only block that could correspond to:
Code:
07:EAF2:A2 00     LDX #$00
07:EAF4:8E 52 00  STX $0052 = #$00
07:EAF7:BD 00 00  LDA $0000,X @ $0001 = #$00
07:EAFA:8D 50 00  STA $0050 = #$01
07:EAFD:20 9B E2  JSR $E29B
07:EB00:CA        DEX;...?
07:EB01:00        BRK
07:EB02:04        UNDEFINED
07:EB03:3F        UNDEFINED

I know because there's only one place in your code that has lda $00,x right above sta $50. So after that JSR, it should do its thing and return to LDX $52 and INX. DEX and BRK have been assembled there instead. Why is this? Because of this:

Code:
.bank 15
  .org $EB00

  .db $CA,$00,$04                                                                                 ; 00 - initial

Do those 3 bytes look familiar? Yep, they're the $CA (DEX), $00 (BRK), $04 (undefined) bytes showing up where your code should be. What probably happened was the code you added with the nametables made your code large enough to hit the what you had reserved for whatever that other stuff was at $EB00.

Basically, you began your code with .org $E000. But it's larger than $B00 bytes. In the same bank, you have a .org $EB00, so there's a collision.

Now, NESASM absolutely should have thrown an error for the collision. I'd like to know if it's the latest version, because that's bad if things like that still happen.

The simple way to fix it is to save 8 (or 9 if you keep that code absolute) bytes in your code. Like Memblers said, NESASM doesn't assume zero page. So saving the eight bytes in your case will be super easy. To force zero page in NESASM, use <

Code:
UpdateTiles:
  LDX #$00
LoadBlock:
  STX <$52
  LDA $00,X
  STA <$50
  JSR IndividualTile
  LDX <$52
  INX
  CPX #$10
  BNE LoadBlock
  RTS

Or if you decide to name your variables:
Code:
variable = $00;At the top of the file once

lda <variable;Anywhere else

That will save a byte everywhere you do it in your code as well make your code faster. And it looks like your code ONLY used zero page variables, so there are lots of saving to be had. (Note: Don't do it for non zero page variables. For clarity the zero page is the RAM from $0000-$00FF. $0100-$7FFF is non zero page RAM.)

_________________
https://kasumi.itch.io/indivisible


Last edited by Kasumi on Sun Aug 02, 2015 8:42 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 8:42 pm 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
You found it! My code was bleeding into a region that was reserved for $EB00. That's why more writes made that happen! Thanks so much.

Other than that, I am using NESASM3. I am currently cleaning up my code for a few reasons:
1) This was my first program so I am noticing a lot of inefficient work.
2) I'm currently naming my variables so it is easier to read.

When I am done, I will repost with the DMC stuff too. I heard before that NESASM3 is more for learning and has definite disadvantages. What compiler is considered the best, and what would I need to do to my .asm file so that it is compatible with the new compiler?


Top
 Profile  
 
PostPosted: Sun Aug 02, 2015 8:59 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1035
NES Assembler 3.1? NES Assembler 3.01? It displays a version when you run it. There are different versions of a file called nesasm3.exe. Does this one also give you a broken ROM without telling you? If so... *sigh*, poor NESasm.

Different people think different things are the best. ASM6 is nearly as simple, and more versatile. Others like CA65/CC65, which are even more versatile, but not as simple. It shouldn't be too difficult to port your code over to asm6 at least. But... if you're planning on doing that, don't use < for zero page stuff.

You'll need to manually create a header, and change some syntax. LDA [$D2],Y becomes LDA ($D2),Y. Most assemblers use () for indirect addressing, actually. I'll let someone else get more specific than that, I haven't used asm6 with mappers too terribly much and don't want to mislead. (I'm still using NESASM, because my project is too large to easily change to anything. My next project will probably use asm6.)

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Mon Aug 03, 2015 3:18 am 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
I was using NESASM 3.0 but switched to 3.1 with this file.

I figured out how to upload my game to a cart and play it on a Nintendo but there is one problem: the sprites are being assigned the wrong tiles. This doesn't happen on the emulators. Maybe I did something wrong in the installation? What I did was:
1) Took my .nes file and trimmed off the first 16 bytes.
2) I cut it in two and created two .bin files, 128 kB PRG and 256 kB CHR.
3) Since I am writing to a TKROM 512 PRG, I was told to pad the PRG so that it will be 512 KiB going onto the cart. So I make four identical copies of my PRG (as I understood from the instructions) and paste all four back-to-back.
4) Upload to cart successful. Plug into top loading NES. Turn on and everything else is fine but the sprites are using the wrong tile selections.

Also, is there a page on nesdev that is dedicated to homebrew developers software? There is some software I would be interested in if it exists. Photo to tiles in a few clicks. A video converter that creates small 2 second videos at 30 frames per second. A dedicated convert to DPCM. I can do all these things the normal way but has anybody shortened the process a little?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 53 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group