I'm very new at this, but I'm having a strange problem:

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
eliza
Posts: 7
Joined: Mon May 02, 2005 1:30 am
Contact:

I'm very new at this, but I'm having a strange problem:

Post by eliza » Mon May 02, 2005 2:54 am

I can't figure out what the 9th consecutive sprite on a horizontal plane won't display. If I move the 9th sprite down by 8px, it will display. If someone could take a look at the code and tell me what I'm doing wrong, I would appreicate it (please ignore some of the strange tabbing, it's a UBB thing, and not in my code):

Code: Select all

	;;--- CODE START ---;;

	; INES header stuff
	.inesprg 1   ; 1 bank of code
	.ineschr 1   ; 1 bank of spr/bkg data
	.inesmir 1   ; something always 1
	.inesmap 0   ; we use mapper 0

	.bank 1   ; following goes in bank 1
	.org $FFFA  ; start at $FFFA
	.dw 0    ; dw stands for Define Word and we give 0 as address for NMI routine
	.dw Start ; give address of start of our code for execution on reset of NES.
	.dw 0   ; give 0 for address of VBlank interrupt handler, we tell PPU not to
	; make an interrupt for VBlank.

	.bank 0   ; bank 0 - our place for code.
	.org $8000  ; code starts at $8000


test = $00
Start:  
	lda #%00001000  ; do the setup of PPU
	sta $2000       ; that we
	lda #%00011110  ; talked about
	sta $2001       ; on a previous day

	ldx #$00    ; clear X

	lda #$3F    ; have $2006 tell
	sta $2006   ; $2007 to start
	lda #$00    ; at $3F00 (pallete).
	sta $2006

loadpal:                ; this is a freaky loop
	lda tilepal, x  ; that gives 32 numbers
	sta $2007       ; to $2007, ending when
	inx             ; X is 32, meaning we
	cpx #32         ; are done.
	bne loadpal     ; if X isn't =32, goto "loadpal:" line.
	ldx #$00

waitblank:         ; this is the wait for VBlank code from above
	lda $2002  ; load A with value at location $2002
	bpl waitblank  ; if bit 7 is not set (not VBlank) keep checking
	lda #$00   ; these lines tell $2003
	sta $2003  ; to tell
	lda #$00   ; $2004 to start
	sta $2003  ; at $0000.

		
	lda #$08

	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$00
        sta $2004

	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$08
        sta $2004
        
 	lda #$08
 	sta $2004
 	lda #$00
 	sta $2004
 	lda #%00000000
 	sta $2004
 	lda #$10
        sta $2004
        
	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$18
        sta $2004
        
	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$20
        sta $2004

	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$28
        sta $2004

	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$30
        sta $2004

	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$38
        sta $2004
        
;this one won't display\/
	lda #$08
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$40
        sta $2004        
        
;this one will \/
	lda #$10
	sta $2004
	lda #$00
	sta $2004
	lda #%00000000
	sta $2004
	lda #$40
        sta $2004 
    
        bne waitblank

infin:
	jmp infin   ; JuMP to infin. note that this loop never ends. :)

tilepal: .incbin "test.pal" ; include and label our pallete

	.bank 2   ; switch to bank 2
	.org $0000  ; start at $0000
	.incbin "test.bkg"  ; empty background first
	.incbin "test.spr"  ; our sprite pic data
	; note these MUST be in that order.

	;;--- WERE DONE / CODE END ---;;

Tom
Posts: 68
Joined: Wed Apr 06, 2005 5:36 am
Location: Massachusetts

Post by Tom » Mon May 02, 2005 5:09 am

The NES can only display 8 sprites per scanline. If you need to have more sprites per scanline, you'll have to rotate the order of the sprites in OAM. This will cause flickering, but at least all the sprites will be visible.
-Tom

User avatar
Bregalad
Posts: 8017
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Mon May 02, 2005 8:57 am

You'd better to search a bit before asking : http://nesdev.com/wiki/?page=NES+PPU
Useless, lumbering half-wits don't scare us.

tepples
Posts: 22322
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I'm very new at this, but I'm having a strange problem:

Post by tepples » Mon May 02, 2005 1:21 pm

eliza wrote:I can't figure out what the 9th consecutive sprite on a horizontal plane won't display.
Because you're not developing for the GBA. Once you make the move from the Nintendo Entertainment System to the Game Boy Advance, you gain the ability to display upwards of 100 sprites on one scanline, and it also becomes a lot easier to test your programs on real hardware because online retailers such as kicktrading.ca sell rewritable GBA cartridges to the public.

:P

Guest

Post by Guest » Mon May 02, 2005 5:19 pm

Sorry, I've done a huge ammount of reading, but I must've missed that. Thanks for the replies everyone, I really appreciate the fast response. Back to the drawing board! :)

User avatar
Bregalad
Posts: 8017
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Sat May 07, 2005 8:17 am

Anonymous wrote:Sorry, I've done a huge ammount of reading, but I must've missed that. Thanks for the replies everyone, I really appreciate the fast response. Back to the drawing board! :)
Well, in regards to that I've posted one year ago, I'd better shut up :
http://nesdev.com/cgi-bin/wwwthreads/sh ... apsed&sb=5
Useless, lumbering half-wits don't scare us.

Post Reply