Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

Nerdy Nights week 5 multiple sprites, reading controllers, more instructions

Jun 4, 2010 at 2:04:38 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
You can only do 8 sprites per scan line, 64 sprites total. I'd imagine there is something wrong with your code. You'd have to post it to get a better answer than that.

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Jun 4, 2010 at 2:59:38 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
I think this is the important part of the code:



.bank 1
.org $E000
palette:
.db $0F,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$0F
.db $0F,$29, $07, $36

sprites:

;------- Dragon--------
.db $10, $02, $00, $10
.db $10, $03, $00, $18
.db $10, $04, $00, $1F ;
.db $18, $12, $00, $10
.db $18, $13, $00, $18
.db $18, $14, $00, $1F;
.db $1F, $22, $00, $10
.db $1F, $23, $00, $18
.db $1F, $24, $00, $1F



.org $FFFA
.dw NMI

.dw RESET

.dw 0

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!


Edited: 06/04/2010 at 03:12 PM by -Basti-

Jun 4, 2010 at 3:21:36 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
What does your sprite loading loop look like?

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Jun 4, 2010 at 3:26:11 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
LoadSprites:
LDX #$00
LoadSpritesLoop:
LDA sprites, x
STA $0200, x
INX
CPX #$20
BNE LoadSpritesLoop

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!


Edited: 06/04/2010 at 03:26 PM by -Basti-

Jun 4, 2010 at 3:30:24 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
Well, assuming that the BNE goes to LoadSpritesLoop, you need CPX #$23 at the bottom. X values, like so:

Sprite 1: 0,1,2,3
Sprite 2: 4,5,6,7
Sprite 3: 8,9,a,b
Sprite 4: c,d,e,f
Sprite 5: 10,11,12,13
Sprite 6: 14,15,16,17
Sprite 7: 18,19,1a,1b
Sprite 8: 1c,1d,1e,1f
Sprite 9: 20,21,22,23

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Jun 4, 2010 at 3:33:36 PM
Roth (67)
avatar
(Rob Bryant) < Lolo Lord >
Posts: 1777 - Joined: 09/14/2006
Illinois
Profile
Bump your X register compare up to #$24. I'd imagine you just forgot to do that after adding the four bytes for another sprite in your sprite table hehe I've done the same thing before : )

Quick question for my own curiosity. How do you add colors to your palette? I've never really seen palette entries stored like that.

EDIT: MRN beat me to it, but it's #$24, as there are 36 bytes total. Bad MRN, BAD! ; )

-------------------------
http://slydogstudios.org...


Edited: 06/04/2010 at 03:35 PM by Roth

Jun 4, 2010 at 3:41:35 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
Oops. Roth is right. I usually set my loops up differently. But, after you load the data in loop 23, you incriment it. So the value is in fact $24.

Kick to the .

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Jun 4, 2010 at 3:45:20 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
Oh man thanks ,I really have missed that one^^
I was editing the NA-tutorial palette and missed to fix the MRN.
I´m new in homebrewing thats the reason of this mistakes :-)

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!

Jun 5, 2010 at 11:19:54 AM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
Now i have another problem. I can´t move the 9th sprite :-(

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!

Jun 7, 2010 at 1:18:31 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
Ok maybe I should depict my problem better.
I´m putting 9 sprites on the screen. With help of NN Chapter 5, I use to move them around but only the first 8 sprites move. Anybody got some advice for me?

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!

Jun 7, 2010 at 2:17:58 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
Are you using meta-sprites? Or are you moving each one individually?

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Jun 7, 2010 at 2:32:18 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
I use the technique which is shown in NN 5, I think that´s moving each sprite individually.
Here´s my code

ReadLeft:
LDA $4016 ; player 1 - Left
AND #%00000001 ; only look at bit 0
BEQ ReadLeftDone ; branch to ReadBDone if button is NOT pressed (0)
; add instructions here to do something when button IS pressed (1)
LDA $0203 ; load sprite X position
SEC ; make sure carry flag is set
SBC #$01 ; A = A - 1
STA $0203 ; save sprite X position
STA $020F ; save sprite X position
STA $021B
CLC
ADC #$08
STA $0207
STA $0213
STA $021F
CLC
ADC #$08
STA $020B
STA $0217
STA $2022

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!

Jun 7, 2010 at 2:45:13 PM
bunnyboy (81)
avatar
(Funktastic B) < Master Higgins >
Posts: 7704 - Joined: 02/28/2007
California
Profile
Originally posted by: -Basti-

STA $2022

Typo!

Jun 7, 2010 at 2:47:59 PM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile

^^ Beat me to it.

The STA $2022 should be STA $2023.

I'd suggest writing out a chart that looks like this:
vert, tile, att, horz
$2000,$2001,$2002,$2003
$2004,$2005,$2006,$2007...etc.

That helped me a lot. And when you get multiple sprites, it helps you keep track of which address manipulates which sprite.


-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.



Edited: 06/07/2010 at 02:48 PM by Mario's Right Nut

Jun 7, 2010 at 3:02:14 PM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
thank you, now it works :-)

-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!


Edited: 06/08/2010 at 06:39 AM by -Basti-

Jun 17, 2010 at 6:25:54 PM
Kreese (4)
avatar
(Robert Kreese) < Little Mac >
Posts: 57 - Joined: 01/31/2007
Sweden
Profile
In this Nerdy Nights, we learn how to read from controllers... Is it hard to make a 4-player game using a four score? Is there any 4-player homebrews out there?

Jun 17, 2010 at 6:37:46 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8126 - Joined: 06/21/2007
Florida
Profile
The latest X-mas 09 cart had 4 player snowball fighting action. Other than that, I don't think so.

I may incorporate 4 players into my latest project, but I haven't decided yet.

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Jun 17, 2010 at 9:26:32 PM
NESHomebrew (21)
avatar
(Brad Bateman - Strange Brew Games) < King Solomon >
Posts: 4266 - Joined: 04/28/2008
Saskatchewan
Profile
Originally posted by: Kreese

In this Nerdy Nights, we learn how to read from controllers... Is it hard to make a 4-player game using a four score? Is there any 4-player homebrews out there?
I think Chu Chu Rocket has four player support planned. http://www.dwedit.org/nes/chuchur...

From the looks of the title screen anyways.

Jun 18, 2010 at 10:22:40 AM
bunnyboy (81)
avatar
(Funktastic B) < Master Higgins >
Posts: 7704 - Joined: 02/28/2007
California
Profile
I have another Nerdy Nights planned for this, but Four Score is really easy. You just need to read $4016/$4017 8 more times without setting the latch to get the buttons for controllers 3 and 4. More info at http://wiki.nesdev.com/w/index.ph...

Sep 24, 2010 at 5:02:14 AM
-Basti- (0)
avatar
(Sebastian D) < Little Mac >
Posts: 67 - Joined: 04/21/2010
Germany
Profile
Hi, I want to make am tile smoothly move. this is my code, but it doesn´t work, can anybody help me?:

LatchController:

LDA #$01
STA $4016
LDA #$00
STA $4016 ; tell both the controllers to latch buttons


ReadA:
LDA $4016 ; player 1 - A
AND #%00000001 ; only look at bit 0
BEQ ReadADone ; branch to ReadADone if button is NOT pressed (0)

fire:
LDA sprite_RAM+68 ;$D8
SBC #$01
STA sprite_RAM+68
;---
LDA sprite_RAM+68
CMP $50
BNE fire

ReadADone:


-------------------------
Looking for NES prototypes!!! Please offer any proto you want to get rid of!


Edited: 09/24/2010 at 05:04 AM by -Basti-

Feb 2, 2011 at 3:06:33 AM
Herbalist (139)
avatar
(Bill Brasky) < King Solomon >
Posts: 4208 - Joined: 08/19/2008
Wisconsin
Profile
Originally posted by: -Basti-

Hi, I want to make am tile smoothly move. this is my code, but it doesn´t work, can anybody help me?:

LatchController:

LDA #$01
STA $4016
LDA #$00
STA $4016 ; tell both the controllers to latch buttons


ReadA:
LDA $4016 ; player 1 - A
AND #%00000001 ; only look at bit 0
BEQ ReadADone ; branch to ReadADone if button is NOT pressed (0)

fire:
LDA sprite_RAM+68 ;$D8
SBC #$01
STA sprite_RAM+68
;---
LDA sprite_RAM+68
CMP $50
BNE fire

ReadADone:


Really, really, late response, and Im a noob, but maybe it didnt work because you didnt put a SEC before your SBC to make sure the carry flag was set



I was also having trouble with my sprites moving in certain direction faster until I realized it was because when I was copying + pasting code I accidentally forgot to change SEC to CLC when I had to add instead of subtract. After I fixed that up my program was fine.



-------------------------



Edited: 02/02/2011 at 03:06 AM by Herbalist

Feb 2, 2011 at 11:22:52 AM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8126 - Joined: 06/21/2007
Florida
Profile
Is sprite_RAM a variable? If you're not actually writing to $0200 or $0300, it won't do anything.

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Feb 2, 2011 at 11:29:48 AM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
Sprite_RAM should be a constant when used in this case.

i.e.
Sprite_RAM = $0200
Then
STA Sprite_RAM+68
means
STA $0244

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Apr 25, 2011 at 12:04:31 PM
JC-Dragon (0)
avatar
(JC Childs) < Eggplant Wizard >
Posts: 388 - Joined: 04/24/2011
United States
Profile
alright w00t! got the back of Mario's head to move! now I just got to get all the different directions to work with the whole sprite!

P.S. I love that the nesasm let's you know which line your errors are being found in. makes troubleshooting a little simpler. Since I'm taking the source that you are giving and manually typing it out myself to get familiar with the syntax and data structure. Sometimes I press the wrong button and poof it doesn't work.

-------------------------
You can't depend on your eyes when your imagination is out of focus
- Mark Twain

Apr 25, 2011 at 1:41:41 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
I can't tell you an assembler that's half modern that doesn't do that, truthfully. It lacks the nicest features IMO (+/- labels!) but it's a decent assembler still.


Forewarning you, though. Don't read the controller and do the sprite movement at the same time. Store the controller value in a variable and reference it later on, because there's lots of parts in games you don't want sprites to move at all. Just telling you this now so you don't have to rediscover this bad coding problem these tutorials don't exactly say not to do.


Edited: 04/25/2011 at 01:41 PM by removed04092017