New Project

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

dsv101
Posts: 36
Joined: Fri Jun 17, 2011 5:16 am
Location: United States
Contact:

Post by dsv101 » Tue Jun 28, 2011 10:58 pm

ok cool, i think i got this :)
~Yeah, I Said That

dsv101
Posts: 36
Joined: Fri Jun 17, 2011 5:16 am
Location: United States
Contact:

Post by dsv101 » Tue Jun 28, 2011 11:27 pm

since a byte = 8 bits, how do i access each individual bit if i want to?
~Yeah, I Said That

User avatar
Memblers
Site Admin
Posts: 3880
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers » Tue Jun 28, 2011 11:54 pm

In short, you use AND to clear bits, ORA to set bits, and EOR to invert bits.

You can also use ASL/LSR/ROL/ROR to move a bit into the carry flag and check the carry flag (BCC/BCS), and using BPL/BMI is a common trick to check the state of the highest bit (even without any other operation, after an LDA is fine, such as you see with the common LDA $2002 / BPL loop)

dsv101
Posts: 36
Joined: Fri Jun 17, 2011 5:16 am
Location: United States
Contact:

Post by dsv101 » Wed Jun 29, 2011 12:06 am

ok man :)
~Yeah, I Said That

dsv101
Posts: 36
Joined: Fri Jun 17, 2011 5:16 am
Location: United States
Contact:

Some sprites wont show

Post by dsv101 » Sat Jul 16, 2011 9:22 pm

Some sprites wont show, and i dont see why.
The second set of 6 wont show, is my compiler screwing up, or am I an idiot?

Code: Select all

sprites:                    ; y tile atr x

  .db $10, $00, $01, $10    ; $0200-$0203 Ship left half
  .db $10, $01, $01, $18    ; $0204-$0207 Shtp Second Half

  .db $10, $03, $01, $20    ; $0208-$020B Bullet
  .db $10, $03, $01, $28    ; $020C-$020F Bullet
  .db $10, $03, $01, $30    ; $0210-$0213 Bullet
  .db $10, $02, $01, $38    ; $0214-$0217 Bullet
  .db $10, $02, $01, $40    ; $0218-$021B Bullet
  .db $10, $02, $01, $48    ; $021C-$021F Bullet

  .db $20, $03, $01, $20    ; $0220-$0223 Bullet
  .db $20, $03, $01, $28    ; $0224-$0227 Bullet
  .db $20, $03, $01, $30    ; $0228-$022B Bullet
  .db $20, $02, $01, $38    ; $022C-$022F Bullet
  .db $20, $02, $01, $40    ; $0230-$0233 Bullet
  .db $20, $02, $01, $48    ; $0234-$0237 Bullet

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Some sprites wont show

Post by cpow » Sat Jul 16, 2011 9:28 pm

dsv101 wrote:Some sprites wont show, and i dont see why.
The second set of 6 wont show, is my compiler screwing up, or am I an idiot?
The data looks OK to me, how about pasting the code that's putting it in RAM and DMAing (or copying via $2003/$2004 perhaps) it to the PPU?

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Post by thefox » Sat Jul 16, 2011 10:08 pm

Open the ROM in Nintendulator (or some other debugger with PPU viewer) and see if the sprites appear in the sprite list. If not, single step through your code to find out why.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

3gengames
Formerly 65024U
Posts: 2277
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames » Sat Jul 16, 2011 10:16 pm

Are you enabling rendering, loading the palettes, and such?

dsv101
Posts: 36
Joined: Fri Jun 17, 2011 5:16 am
Location: United States
Contact:

Post by dsv101 » Sun Jul 17, 2011 1:08 pm

Code: Select all

LoadPalettes:
  LDA $2002
  LDA #$3F
  STA $2006
  LDA #$00
  STA $2006
  LDX #$00
LoadPalettesLoop:
  LDA palette, x
  STA $2007
  INX
  CPX #$20
  BNE LoadPalettesLoop



LoadSprites:
  LDX #$00
LoadSpritesLoop:
  LDA sprites, x
  STA $0200, x
  INX
  CPX #$20
  BNE LoadSpritesLoop

  LDA #%10000000
  STA $2000

  LDA #%00010000
  STA $2001
~Yeah, I Said That

3gengames
Formerly 65024U
Posts: 2277
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames » Sun Jul 17, 2011 1:13 pm

Are the sprites in the 1st graphics table? Other than that, looks perfectly fine to me.

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Post by cpow » Sun Jul 17, 2011 1:24 pm

Where's the:

Code: Select all

   lda #2
   sta $4014
There's only code there to set up the sprite RAM area. Not that that is the problem...it's just hard to tell what might be wrong with only snippets.

EDIT: Nevermind in this case the problem is obvious after looking again:

Code: Select all

LoadSpritesLoop:
  LDA sprites, x
  STA $0200, x
  INX
  CPX #$20
  BNE LoadSpritesLoop 
You have way more than 32 bytes of sprite data...so you're cutting off the copy loop too early.

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq » Sun Jul 17, 2011 1:26 pm

Do you see the "cpx #$20" line? That controls how many bytes you are loading into your sprite RAM. $20 is 32 in decimal, or 8 sprite's worth of data. You have 56 bytes of data for 14 sprites. So change the "cpx #$20" to "cpx #56" and it should all work.

Each time you add or remove sprites from that table you'll need to change that line. Sounds like a great use for an EQU statment.

Example:

Code: Select all

.equ sprite_data_length 56
; 56 bytes of sprite data

; ...In your loading loop...
cpx #sprite_data_length
That way you'll only have to change the EQU line and not have to go hunting through your code.

Got ninja'ed, but yea

3gengames
Formerly 65024U
Posts: 2277
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames » Sun Jul 17, 2011 1:31 pm

Damn, didn't think that was the problem. Sorry dude. But anyway, CPX compares X to a number, you go that right? When the INX and it ups it by 1, you compare to find the end. That makes sense right?

dsv101
Posts: 36
Joined: Fri Jun 17, 2011 5:16 am
Location: United States
Contact:

Post by dsv101 » Sun Jul 17, 2011 3:53 pm

yes 3gen, i know what that does. I didnt cacy that #$20 in there like i should have, thanks guys.
~Yeah, I Said That

3gengames
Formerly 65024U
Posts: 2277
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames » Sun Jul 17, 2011 5:09 pm

Okay, just wanted to make sure you understood that. Is it working now okay?

Post Reply