Page 6 of 7

Posted: Tue Jun 28, 2011 10:58 pm
by dsv101
ok cool, i think i got this :)

Posted: Tue Jun 28, 2011 11:27 pm
by dsv101
since a byte = 8 bits, how do i access each individual bit if i want to?

Posted: Tue Jun 28, 2011 11:54 pm
by Memblers
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)

Posted: Wed Jun 29, 2011 12:06 am
by dsv101
ok man :)

Some sprites wont show

Posted: Sat Jul 16, 2011 9:22 pm
by dsv101
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

Re: Some sprites wont show

Posted: Sat Jul 16, 2011 9:28 pm
by cpow
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?

Posted: Sat Jul 16, 2011 10:08 pm
by thefox
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.

Posted: Sat Jul 16, 2011 10:16 pm
by 3gengames
Are you enabling rendering, loading the palettes, and such?

Posted: Sun Jul 17, 2011 1:08 pm
by dsv101

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

Posted: Sun Jul 17, 2011 1:13 pm
by 3gengames
Are the sprites in the 1st graphics table? Other than that, looks perfectly fine to me.

Posted: Sun Jul 17, 2011 1:24 pm
by cpow
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.

Posted: Sun Jul 17, 2011 1:26 pm
by qbradq
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

Posted: Sun Jul 17, 2011 1:31 pm
by 3gengames
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?

Posted: Sun Jul 17, 2011 3:53 pm
by dsv101
yes 3gen, i know what that does. I didnt cacy that #$20 in there like i should have, thanks guys.

Posted: Sun Jul 17, 2011 5:09 pm
by 3gengames
Okay, just wanted to make sure you understood that. Is it working now okay?