It is currently Wed Aug 23, 2017 6:18 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Thu Jul 27, 2017 4:24 pm 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 799
Location: Gothenburg, Sweden
I thought i had this down. It's a bit embarrasing. I've managed sprites on their own, and backgrounds on their own. The aim is a simple still picture comprised of both sprite and bg layer.

My include list looks like this:

Code:
.segment "CHRROM"
.incbin "spritesheet.chr" ;4k
.incbin "bgsheet.chr" ;4k
.incbin "nametable.nam" ;1k

Palette is hardcoded for now.
BG loading code looks like this:
Code:
lda #$90     ; CPU addr $8000+ 4kB offset
sta ptr+1     
sty ptr+0  ;y reg is known to be zero
   
lda #$10   ;headache be here, i think?
sta PPUADDR   
sty PPUADDR 
 
ldx #20      ; + 20 pages' worth - 16 for bg chr and 4 for nt

loop:   
   lda (ptr), y
   sta PPUDATA
   iny   
   bne loop    ; done a page yet?  (y reg)
   inc ptr+1   
   dex       
   bne loop    ; done all pages yet? (x reg)

This this seems to put the NT where i want it (i can tell by the attribute table), but not the pattern table. If i change PPU addr to $0000 via sty PPUADDR sty PPUADDR (the way i had it originally), i can get the pattern but not the attribute/name table. What have i done to not get both?

_________________
http://www.frankengraphics.com - personal NES blog


Last edited by FrankenGraphics on Thu Jul 27, 2017 4:28 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 4:27 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6043
Location: Seattle
Why are your tiles and nametable both in a chrrom segment? Is that just a misnomer?

Have you set $2000 correctly for rendering? (It shouldn't affect loading tiles, tho...)


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 4:46 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9916
Location: Rio de Janeiro - Brazil
Is your "CHRROM" segment in PRG-ROM and you're in fact using CHR-RAM? That's confusing... Anyway, I can't tell what's wrong just from this section of code... The full code or even the ROM would make debugging easier.


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 6:12 pm 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 799
Location: Gothenburg, Sweden
Oh, that's a misnomer i accidentally carried across from studying a config file to get clues on how to do it. Which was NROM, i realize now. It should be RODATA. It's late here but i'll update tomorrow! Thanks so far on the leads

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 7:27 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 274
What's in your NMI? Sounds like you're not resetting the scroll after writing the pattern table.


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 9:02 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2926
Location: Tampere, Finland
Try stepping through the code in an emulator's debugger. For example in FCEUX you can have the hex editor (set to PPU Memory) open while stepping to verify that the data is going where it should.

As for the actual issue, my guess is the same as Rahsennor's.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Fri Jul 28, 2017 1:17 pm 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 799
Location: Gothenburg, Sweden
Thanks, all!

Allright, here's the project in a zip (source, assets, rom). Both patterns are loaded, so is nametable and palette. So it's "working", but feels a bit rickety.
NMI currently got cut as it doesn't do anything useful just yet. The config got a few mistakes ironed out, too. But i think the problem was an erronously set bit in PPUCTRL and/or having data in the "wrong" bank (suspicious).

New questions:
-Why does the problem persist when i try to move the graphics data to bank0? (from line 190 to line 42).
-Why do i have to load the palette address at line 103?
-In the config, what good does the align setting do?

Pardon the nonexistent init.


Attachments:
dungeon_companion.zip [19.06 KiB]
Downloaded 12 times

_________________
http://www.frankengraphics.com - personal NES blog
Top
 Profile  
 
PostPosted: Sat Jul 29, 2017 12:00 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2926
Location: Tampere, Finland
Code:
   clc ;set a known condition
loop_forever:
   bcs loop_forever

See anything wrong? :)

FrankenGraphics wrote:
-In the config, what good does the align setting do?

It aligns the segment in the MEMORY block where it was assigned. In your case since the OAM segment is the only thing that goes into the OAM memory block, you don't really need it. Note, however, that if you want to use .align in code, cc65 requires that the corresponding segment is aligned (in the linker configuration) to some multiple of the value given to .align.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Jul 29, 2017 12:38 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 799
Location: Gothenburg, Sweden
Haha! *makes a known condition* *actively ignores it*

Ah, thanks. That makes sense. But segments will never overwrite each other, since the PC can't move backwards at assembly time, right?

In case someone doesn't want to download, here's the code:
https://pastebin.com/KJAfVTaz

And the whole thing again with that loop fix.
Attachment:
170729.zip [19.08 KiB]
Downloaded 6 times

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Sat Jul 29, 2017 1:01 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2926
Location: Tampere, Finland
FrankenGraphics wrote:
But segments will never overwrite each other, since the PC can't move backwards at assembly time, right?

They don't.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot], tokumaru and 6 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:  
Powered by phpBB® Forum Software © phpBB Group