6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 8:48 am

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Sep 09, 2014 11:49 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 411
Location: Minnesota
Well, #240 may have been a little high as a starting value for the X-register.

As for the code that didn't put down the initial 'H', I didn't see any initialization of the Y-register. Was it there and just left out of what you posted?


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 10, 2014 1:06 am 
Offline

Joined: Fri Nov 09, 2012 6:52 am
Posts: 16
What's wrong with #240 ?..
Oops.
Well this code was based off of just clearing the nametable with a single value..
This change should fix it:

Code:
  ; replace symbol names with your names..
    ; PPU_NAMETABLEADDRESS - where you want to write
    ; p - your pointer
    ; myData - data you want to write
    ; PPU_ADDRESS ; $2006
    ; PPU_DATA ; $2007

    ; set PPU address
    lda #>PPU_NAMETABLEADDRESS
    sta PPU_ADDRESS ; $2006
    lda #<PPU_NAMETABLEADDRESS
    sta PPU_ADDRESS

    ; nametable is 32 x 30 = 960
    ; this loop is 240 x 4 = 960
   
    lda #<mydata
    sta p
    lda #>mydata
    sta p+1

    ldy #0
    ldx #240 
 
    loop:
        lda (p), y
        sta PPU_DATA
        iny

        lda (p), y
        sta PPU_DATA
        iny

        lda (p), y
        sta PPU_DATA
        iny

        lda (p), y
        sta PPU_DATA
        iny
       
        bne skip
        inc p+1
        skip:
    dex
    bne loop


Though I am liking barrym95838's code more at this point.

This idea does work well if you are just setting the nametable to a certian value:

Code:
    ; set PPU address
    lda #>PPU_NAMETABLEADDRESS
    sta PPU_ADDRESS ; $2006
    lda #<PPU_NAMETABLEADDRESS
    sta PPU_ADDRESS

    ; nametable is 32 x 30 = 960
    ; this loop is 240 x 4 = 960
   
    lda #0
    ldx #240 
 
    loop:
        sta PPU_DATA
        sta PPU_DATA
        sta PPU_DATA
        sta PPU_DATA
    dex
    bne loop


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 10, 2014 8:20 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Baka94 wrote:
Unfortunately [some] code didn't work. I just got a messed up mix of 0 and blank tiles (like usually when it doesn't work). I was hoping it would have worked tough.

It's not at all unusual when programming down in assembly language that code doesn't quite work. It's worth having some tactics ready to deal with this:
- a careful manual read-through, considering each instruction's effect on registers, flags, and memory.
- single-stepping using an emulator or machine code monitor.
- modifying the misbehaving code, producing output or writing to memory so as to leave some idea of what happened when.

There are surely others too!

Hope this helps
Ed


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 10, 2014 9:46 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
Single-stepping (on an emulator or the hardware, if the latter is possible) is actually fun when you get down to it. Look at the registers and important memory locations after each step, and soon you'll see what happens. Very rewarding when you figure it out.

-Tor


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 06, 2014 8:48 am 
Offline

Joined: Sun Feb 23, 2014 1:45 pm
Posts: 12
Just letting you know that I got the 16 bit counter working. The reason why it looked like it didn't, was that I had the PPU turned on when I drew the background. Anyway, thanks for the help. I'm off to learn how to use NMI and VBlank. :)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


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: