It is currently Sun Dec 09, 2018 4:51 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Sun Apr 16, 2006 5:38 am 
Offline
User avatar

Joined: Sun Mar 19, 2006 12:37 am
Posts: 223
Location: San ANto, TX
Memblers wrote:
DEX in that case, starting with 4, lets the outer part of the loop run 4 times. So it'll copy 256 bytes 4 times, 1024 bytes.


So basically it does it four times becasue the there are 4 Nametables each 256 bytes, right?

Also, that number you threw out, $8134:

Code:
nametable: .incbin "bg.nam" ; assume this is at $8134 in ROM


That was just an example, right? the real numbers have to range from the selected nametable addresses, right? Let say i wanted to use Nametable 3 (2c00-2fbf) as and example. Do i always have to start from 2c00. Let say i wanted to start from 2c10. Can i do it as long as the data wont over flow?

Also again real quick
$0004 = 4 and
$400 = 400 right?

Thanks again


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 6:24 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20848
Location: NE Indiana, USA (NTSC)
nineTENdo wrote:
Memblers wrote:
So it'll copy 256 bytes 4 times, 1024 bytes.

So basically it does it four times becasue the there are 4 Nametables each 256 bytes, right?

It is only writing one nametable (1024 bytes) in four 256-byte sections, which are big enough for an 8-bit CPU to handle.

Quote:
Let say i wanted to use Nametable 3 (2c00-2fbf) as and example. Do i always have to start from 2c00. Let say i wanted to start from 2c10. Can i do it as long as the data wont over flow?

Nametables must always start at $2000, $2400, $2800, or $2C00 in PPU space.

Quote:
Also again real quick
$0004 = 4 and
$400 = 400 right?

$400 = 1024


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 12:31 pm 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 339
Location: Phoenix, AZ
Quote:
Let say i wanted to use Nametable 3 (2c00-2fbf) as and example. Do i always have to start from 2c00. Let say i wanted to start from 2c10.


no but remember that the tiles drawn to the screen wont start in the top left corner, but wherever on the screen the memory location you chose represents

Quote:
Can i do it as long as the data wont over flow?


if you load 1024 bytes to a name table and dont start at the beginning, data will over flow


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 1:48 pm 
Offline
User avatar

Joined: Sun Mar 19, 2006 12:37 am
Posts: 223
Location: San ANto, TX
tepples wrote:
$400 = 1024


How does that work
i divide 20/32 gives me 1.6 i mulitpy that by 400 = like 640

what is the logic?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 2:25 pm 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 339
Location: Phoenix, AZ
first look at an equilvalent decimal example: 345
(3 * 100) + (4 *10) + (5) = 345

now $400 is a hexidecimal number:
(4 * $100) + (0 * $10) + ($0) = $400

convert the hex to decmials:
(4 * 256) + (0 * 16) + (0) = 1024

therefore $400 = 1024

a good starting place for 6502 assembly would to read "programming the 6502" by rodnay zaks. i bought the book on e-bay for like $10.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 6:35 pm 
Offline
User avatar

Joined: Sun Mar 19, 2006 12:37 am
Posts: 223
Location: San ANto, TX
Yep i forgot about that i was reading abook on 6800 before i started up with 6502 thier pretty much the same,but thanks for the info.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 12:07 pm 
Offline
User avatar

Joined: Wed Aug 03, 2005 3:15 pm
Posts: 394
Okay, I've tried implementing the code that you posted, never-obsolete. I can't seem to get it to work though:

Code:
        .inesprg    1
        .ineschr    1
        .inesmir    1
        .inesmap    0

   .org $8000
   .bank 0

addrLO = $00
addrHI = $20

Start:
   SEI
   CLD
   LDA #$00
   STA $2000
   STA $2001
   LDX #$02
begloop:
   LDA $2002
   BPL begloop
   DEX
   BPL begloop
   TXS

   lda #%00001000     
   sta $2000         
   lda #%00011110
   sta $2001

        lda #$3F        ;set ppu to start of palette
        sta $2006       
        lda #$00       
        sta $2006
   ldx #$00

loadpal:
   lda titlepal, x  ;loads a 32 byte palette
   sta $2007
   inx
   cpx #$20      ;gotta be one extra b/c of inx
   bne loadpal

Loop:
   jsr vwait

        lda #$20        ;set ppu to start of VRAM
        sta $2006       
        lda #$20     
        sta $2006

   lda #low(lvl1sht)
   sta addrLO
   lda #high(lvl1sht)
   sta addrHI

   jsr loadlevel1

; other junk to try and implement later goes around here

loadlevel1:
   ldx #4
   ldy #0

feedlevel1:
   lda (addrLO), y
   sta $2007
   iny
   bne feedlevel1
   inc addrHI
   dex
   bne feedlevel1
   rts

   jmp Loop

vwait:   
   lda $2002
   bpl vwait
   rts

titlepal:
   .incbin "bckgrnd.pal"



   .bank 1                 ;needed or NESASM gets cranky
   .org   $FFFA   ;ditto
   .dw   0    ;(NMI_Routine)
   .dw   Start    ;(Reset_Routine)
   .dw   0    ;(IRQ_Routine)

       .bank 2
       .org    $C000
       .incbin "bckgrnd.chr"

   .bank 3
   .org    $D000
lvl1sht:   .incbin "bckgrnd.nam"


What's going wrong with it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 12:13 pm 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 339
Location: Phoenix, AZ
here is the problem:

Code:
   .org $8000
   .bank 0

addrLO = $00
addrHI = $20


both must be in zero page for indirect,y addressing:

Code:
   lda (addrLO), y


and, from my understanding inc addrHI would keep incrementing $20 to $21 if placed in rom


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 12:48 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
Most assembler's I've seen use that '=' syntax as variable assignment. IE:

Code:
addrLO = $00
addrHI = $20

LDA addrLO  ; this line is the same as the below line
LDA $00

INC addrHI  ; this line is the same as the below line
INC $20


The problem here is that addrHI isn't placed next to addrLO like it should be:

Code:
LDY #$00
LDA (addrLO),Y  ; this will get the address from $00 and $01!!!  not from $20!


So the problem I see is that addrHI should be $01 and not $20.


Of course in my opinion, a better solution than changing addrHI would be to completely get rid of addrHI and just use 'addr' and 'addr+1':

Code:
LDA #__low_byte_of_address__
STA addr
LDA #__high_byte_of_address__
STA addr+1

LDY #$00
LDA (addr),Y  ; yay!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 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