It is currently Sat Aug 18, 2018 3:16 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Sat Jan 28, 2006 10:04 am 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
WedNESday wrote:
The latch is a 1-bit PPU value that decides between a high and low byte write. If the latch is not set then the next write to $2006 will be to the upper byte (i.e. $xx00). If it is set then the next write will be to the lower byte (i.e. $00xx).


Understand. What is the default for the latch?

EDIT: and when am I suppose to apply the above type code? Before I
write the nametable information or after?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 11:25 am 
Offline

Joined: Thu Sep 15, 2005 9:23 am
Posts: 1194
Location: Behind you with a knife!
lynxsolaris wrote:
WedNESday wrote:
The latch is a 1-bit PPU value that decides between a high and low byte write. If the latch is not set then the next write to $2006 will be to the upper byte (i.e. $xx00). If it is set then the next write will be to the lower byte (i.e. $00xx).


Understand. What is the default for the latch?

EDIT: and when am I suppose to apply the above type code? Before I
write the nametable information or after?


The default value of the latch is 0. when you write to either $2005/$2006 the latch is flipped. If you read from $2002 then the latch is reset.

_________________
http://www.jamesturner.de/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 12:27 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
Do not expect the latch to be 0 on startup. You must never assume the state of any unprepped memory unless you specifically set it first.

Always, always read $2002 at least once in your program before you perform any $2005 / $2006 writes. This will ensure the latch is clear (making your next write the "first" write)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 1:54 pm 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
Ok I must still be missing something.... Is there something else I'm suppose
to be doing before

Code:

 lda #$23
 sta $2006
 lda #$C0
 sta $2006
 lda #%xxxxxx01
 sta $2007



Because I don't have any color change. It's still using the first 4 colors
in my palette. I've tried changing #%xxxxxx01 to xx01xxxx but I didn't
see any change. I've loaded my nametable into $2000 and my
background palette colors into $3F00. I also am reading $2002 at the
beginning before any $2005/$2006 writes.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 8:08 pm 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
Ok guys I'm failing miserably .... I'm at the mercy of this board! Plllleeeaaasse help ... hating some attribute tables right now...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 8:35 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20413
Location: NE Indiana, USA (NTSC)
You don't actually use x's in the byte. For now just try the checkerboard method: write %01000001 in the whole attribute table and see how your screen changes.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 8:48 pm 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
tepples wrote:
You don't actually use x's in the byte. For now just try the checkerboard method: write %01000001 in the whole attribute table and see how your screen changes.


:lol: yeah I know not to use x's. I had been trying it with 0's like
#%00000001 etc. I did as you instructed but had no change. I'm doing
this write after I do my name table stuff. Could that be the problem?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 10:43 pm 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
here is what I have in its entirety ... well almost...

Code:
 .inesprg 1
 .ineschr 1
 .inesmir 0
 .inesmap 0
    
 .zp
scrollPos = $00

 .bss          ; non-zero page memory allocation
               ; $700+ for RAM

; ==================================
;  Memory Allocation
; =================================

... omitted for space ...

; ==================================
; Begin Code
; ==================================

 .code         
 .org $8000    
 .bank 0

main:
 sei         
 cld 
 lda #$00
 sta <scrollPos       
 ldx #$ff    
 txs         
 inx         
 stx $2000   
 stx $2001   

 jsr wait_vblank
 ;jsr clr_spr
 jsr wait_vblank
 jsr clr_spr
 jsr palette
 jsr nametable
 jsr inits
 jsr ppuinit
end:
 jmp end

wait_vblank:
 bit $2002   
 bpl wait_vblank
 rts

clr_spr:     
 lda #0      
 tay      
clr2_spr:
 sta $700,y   
 iny      
 bne clr2_spr 
 rts

; =================================
; Color Palette (Background & Sprites)
; =================================

palette:
 lda #$3F
 sta $2006
 lda #$10
 sta $2006

 lda #$0d
 sta $2007
 lda #$08
 sta $2007
 lda #$28
 sta $2007 
 lda #$19
 sta $2007

 lda #$3F
 sta $2006
 lda #$00
 sta $2006
 
 lda #$0D
 sta $2007
 lda #$30
 sta $2007
 lda #$22
 sta $2007
 lda #$16
 sta $2007
 lda #$0D
 sta $2007
 lda #$00
 sta $2007
 lda #$10
 sta $2007
 lda #$30
 sta $2007
 lda #$0D
 sta $2007
 lda #$00
 sta $2007
 lda #$16
 sta $2007
 lda #$30
 sta $2007
 lda #$0D
 sta $2007
 lda #$3C
 sta $2007
 lda #$1B
 sta $2007
 lda #$09
 sta $2007
 rts

; =======================
; Name table setup
; =======================

nametable:
 lda #$20
 sta $2006
 lda #$80
 sta $2006
 ldy #64
 lda #$04
ceiling:
 sta $2007
 dey
 bne ceiling

 lda #$23
 sta $2006
 ldx #$40
 stx $2006 ; name table @ $2300
 ldy #96
 lda #$04
drawfloor:
 sta $2007
 dey
 bne drawfloor



 
 ; attribute table ... WTF ....
 lda #$23
 sta $2006
 lda #$C0
 sta $2006
 

 lda #%01000001
 sta $2007

 rts
      
; =======================
; Initialization of Sprite
; =======================
 
inits:

... omitted for space ...
 
 rts

; ========================
; PPU Init
; ========================

ppuinit:
 lda #%10001010 ;
 sta $2000   
 lda #%00011010
 sta $2001   

 rts
; =========================
; NMI Routine
; =========================

nmi:

 lda #%10001000
 sta $2000
 lda scrollPos
 ldx #$00
 sta $2005
 stx $2005

 jsr controlStrobe   ; read controller   
 jsr dmatrans
int:
 rti

 
controlStrobe:
 lda #$01
 sta $4016
 lda #$00
 sta $4016
 
 lda $4016 ; A button .. nothing for now
 lda $4016 ; B button  ...
 lda $4016 ; Select
 lda $4016 ; Start
 lda $4016 ; Up
 lda $4016 ; down
 lda $4016 ; Left
 and #1
 beq Right_Press
 dec scrollPos
Right_Press:
 lda $4016 ; Right
 and #1
 beq stop_rts
 inc scrollPos
stop_rts:
 rts
 
 
dmatrans:
 lda #7      
 sta $4014   
 rts

 .bank 1
 .org $fffa
 .dw nmi,main,int
 .bank 2
 .org $0000
 .incbin "img.chr"



Maybe this will help you see where my problem is ....

Thanks for everyones help!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 29, 2006 1:17 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7471
Location: Chexbres, VD, Switzerland
Well, each attribute byte covers 4 colors for 4 group of tiles. Each 2 bit is a color.
At PPU $23c0 : %ddccbbaa
a = color of tiles $0, $1, $20, $21
b = color of tiles $2, $3, $22, $23
c = color of tiles $40, $41, $60, $61
d = color of tiles $42, $43, $62, $63

If you don't have too much experience with nametables, tiles are disposed as folowwing :
$0, $1, $2, $3, ...
$20, $21, $22, $23 ....
$40, $41, $42, $43 ....

Each row is $20 tiles wide.

Now, the 8 first attribute bytes (PPU $23c0-$23c7) controls overall colors for tiles $0-$7f (the first 4 rows of tiles), $23c8-$23cf controls the 4 following rows, etc...
The last 8 attribute bytes ($23f8-$23ff) controls color only for 2 rows instead of 4. The upper nybble (upper 4 bits) of theese byte is "dummy", because the nametable stops after $23c0.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 29, 2006 12:34 pm 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
Bregalad wrote:
Well, each attribute byte covers 4 colors for 4 group of tiles. Each 2 bit is a color.
At PPU $23c0 : %ddccbbaa
a = color of tiles $0, $1, $20, $21
b = color of tiles $2, $3, $22, $23
c = color of tiles $40, $41, $60, $61
d = color of tiles $42, $43, $62, $63

If you don't have too much experience with nametables, tiles are disposed as folowwing :
$0, $1, $2, $3, ...
$20, $21, $22, $23 ....
$40, $41, $42, $43 ....

Each row is $20 tiles wide.

Now, the 8 first attribute bytes (PPU $23c0-$23c7) controls overall colors for tiles $0-$7f (the first 4 rows of tiles), $23c8-$23cf controls the 4 following rows, etc...
The last 8 attribute bytes ($23f8-$23ff) controls color only for 2 rows instead of 4. The upper nybble (upper 4 bits) of theese byte is "dummy", because the nametable stops after $23c0.



OK!!! I think I'm starting to finally understand. The tile that I'm using
as my floor (which I'm trying to change the color of) is tile $4 and $5.
So that would be the reason the color isn't changing because because its
not in that first group of tiles (as you listed above a,b,c,d). So would this
be where bit shifting would come into play?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 29, 2006 6:35 pm 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
MUWAHAHAHAHAHAHAHA! It hit me in the face like being slapped by a
pissed ex-girlfriend! Thanks to everyone who explained it to me. I've got
it! In your face attribute tables. Definitely hardcore though.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:57 am 
Offline

Joined: Thu Sep 15, 2005 9:23 am
Posts: 1194
Location: Behind you with a knife!
lynxsolaris wrote:
...Definitely hardcore though.


Well not for us it wasn't. Explaining it to you though, was.

_________________
http://www.jamesturner.de/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 8:25 am 
Offline
User avatar

Joined: Tue Jan 17, 2006 10:39 am
Posts: 143
Location: North Carolina
WedNESday wrote:
Well not for us it wasn't. Explaining it to you though, was.


Yeah well now its not a problem for me either.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 8:44 am 
Offline
User avatar

Joined: Thu Nov 11, 2004 5:30 am
Posts: 121
Location: San Francisco, CA
WedNESday wrote:
Well not for us it wasn't. Explaining it to you though, was.


That type of attitude isn't appropriate for a newbie forum. If you'd like to help, by all means, contribute. If not, you should refrain from issuing discouraging remarks.

_________________
...patience...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 1:02 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10714
Location: Rio de Janeiro - Brazil
WedNESday wrote:
Well not for us it wasn't. Explaining it to you though, was.


Attributes are so easy, right WedNESday? I bet you never had any problems with them. *cough* http://nesdev.com/bbs/viewtopic.php?t=824 *cough*


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users 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