It is currently Fri Nov 17, 2017 10:25 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sat Sep 20, 2014 12:34 am 
Offline
User avatar

Joined: Sat May 31, 2014 4:12 pm
Posts: 139
I am using the MMC3 mapper and compiling with NESASM3. I am using the following iNES header:

Code:
  .inesmap 4   ; mapper 4 = MMC3
  .inesprg 8
  .ineschr 8
  .inesmir 3   ; background mirroring

I set up my MMC3 settings with the following:

Code:
LDA #%01000010
STA $8000

this write says that I will be using two 2 KB banks at PPU $0000-$0FFF, and four 1 KB banks at PPU $1000-$1FFF which is what I want. Also, this write sets up my next write so that I am about to bank switch the 1 KB bank at PPU $1000-$13FF with whatever bank number I select to write to $8001.

I have a single 32K .chr file I'm including for all my graphics. Also, since I have selected .inesprg 8, then I understand that banks 0 through 15 are for the CPU. I have included the file by this method:

Code:
  .bank 16
  .org $0000
  .incbin "tiles.chr"

Question: Under the settings I have, what bank numbers represent which sections of my tiles.chr? For example, how could I take the information at $4000-$43FF of my tiles.chr and bank switch that into the PPU at say, PPU $1000-$13FF?


Top
 Profile  
 
PostPosted: Sat Sep 20, 2014 1:35 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
NESASM can be kinda weird sometimes... I believe that the .bank statements are mandatory every 8KB, so maybe including a 32KB CHR file at once might not work. I can't tell for sure, since I don't use this assembler, so hopefully someone else will confirm this.

raydempsey wrote:
Question: Under the settings I have, what bank numbers represent which sections of my tiles.chr? For example, how could I take the information at $4000-$43FF of my tiles.chr and bank switch that into the PPU at say, PPU $1000-$13FF?

You select the target location for the tiles by writing to $8000. If your goal is to map the tiles to $1000-$13FF, that would mean that you have the second pattern table broken up in 4 1KB chunks, and you should set the lower 3 bits of the $8000 write to 010 (2), to tell the mapper you'll be mapping tiles into the first 1Kb slot. Then simply write the bank index to $8001. Since you want the bank located $4000 bytes into the CHR file, and each bank is 1KB ($400 bytes) large, the bank number is $4000 / $400 = $10, or 16 in decimal. When bankswitching 2KB CHR banks, the lower bit of the bank index is ignored. This means that to select the third 2KB bank, you'll not be writing 3 to $8001, you'll write 6, because the banks are twice as large as the 1KB ones.

All of this is written in the wiki page, be sure to check it out if you haven't already: http://wiki.nesdev.com/w/index.php/MMC3


Top
 Profile  
 
PostPosted: Sat Sep 20, 2014 2:06 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2978
Location: Tampere, Finland
tokumaru wrote:
NESASM can be kinda weird sometimes... I believe that the .bank statements are mandatory every 8KB, so maybe including a 32KB CHR file at once might not work. I can't tell for sure, since I don't use this assembler, so hopefully someone else will confirm this.

From what I can remember including it all at once won't work. NESASM is also really shitty with error messages in situations like this. I believe hearing this "bank crossing" works in zzo38's modified version of NESASM, although I haven't used it myself.

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


Top
 Profile  
 
PostPosted: Sat Sep 20, 2014 4:53 am 
Offline

Joined: Wed Feb 17, 2010 5:42 pm
Posts: 359
Location: Denine's Devil Mansion
thefox wrote:
From what I can remember including it all at once won't work. NESASM is also really shitty with error messages in situations like this. I believe hearing this "bank crossing" works in zzo38's modified version of NESASM, although I haven't used it myself.

I'm using a NESASM all the time and I can say with all confidence it does work. Even more-I'm making a MMC3 project right now. The "bank crossing" applies only to code, not data. Getting the right Bank number can be hard if you have a big chr, however, so I would split it.

Quote:
Question: Under the settings I have, what bank numbers represent which sections of my tiles.chr?

You start from zero. So if you write 0 to $8001 as your bank number, then the beggining of the chr data will be used and placed into ppu. How many tiles and where exactly depends on $8000 setting.

Quote:
For example, how could I take the information at $4000-$43FF of my tiles.chr and bank switch that into the PPU at say, PPU $1000-$13FF?

Code:
lda #%00000010
sta $8000                    ; So our piece of chr will be put into $1000-$13FF in ppu

lda #$10
sta $8001                    ;Take our piece of chr data and put it into ppu.


Top
 Profile  
 
PostPosted: Sat Sep 20, 2014 5:18 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2978
Location: Tampere, Finland
Denine wrote:
I'm using a NESASM all the time and I can say with all confidence it does work. Even more-I'm making a MMC3 project right now. The "bank crossing" applies only to code, not data. Getting the right Bank number can be hard if you have a big chr, however, so I would split it.

Ah, I stand corrected. It's kind of quirky because NESASM allows overwriting data in existing banks. I guess that feature also makes it impossible to report bank overflows.

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


Top
 Profile  
 
PostPosted: Sat Sep 20, 2014 6:39 am 
Offline

Joined: Wed Feb 17, 2010 5:42 pm
Posts: 359
Location: Denine's Devil Mansion
thefox wrote:
Denine wrote:
I'm using a NESASM all the time and I can say with all confidence it does work. Even more-I'm making a MMC3 project right now. The "bank crossing" applies only to code, not data. Getting the right Bank number can be hard if you have a big chr, however, so I would split it.

Ah, I stand corrected. It's kind of quirky because NESASM allows overwriting data in existing banks. I guess that feature also makes it impossible to report bank overflows.

I just double checked that. NESASM reports happen for the code and for byte\word declarations like .db or .dw. There is no reports for .incbin where included binary file is bigger than space left in the current bank.
The overwriting data in existing banks is not completly correct. The included binary file will be included as a whole if there is no next bank declaration.
For example, our "example.bin" is 16kb in size.
Code:
.bank 0
 .org $8000
 .incbin "example.bin"

 .bank 2
 .org $C000
;anything in here

 .bank 3
 .org $E000
;anything in here

In example above, the example.bin will be included, first half will be in bank 0, the other one in bank 1.

But if you declare bank 1 existance...
Code:
.bank 0
 .org $8000
 .incbin "example.bin"

 .bank 1
 .org $A000
;anything in here

 .bank 2
 .org $C000
;anything in here

 .bank 3
 .org $E000
;anything in here

Then only first 8kb will be included , the other half of the "example.bin" will be cut and removed. There will be no report of the overflow as well :\


Top
 Profile  
 
PostPosted: Sun Sep 21, 2014 12:34 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
Denine wrote:
thefox wrote:
Denine wrote:
I'm using a NESASM all the time and I can say with all confidence it does work. Even more-I'm making a MMC3 project right now. The "bank crossing" applies only to code, not data. Getting the right Bank number can be hard if you have a big chr, however, so I would split it.

Ah, I stand corrected. It's kind of quirky because NESASM allows overwriting data in existing banks. I guess that feature also makes it impossible to report bank overflows.

I just double checked that. NESASM reports happen for the code and for byte\word declarations like .db or .dw. There is no reports for .incbin where included binary file is bigger than space left in the current bank.
Yes, the "bank crossing" features are only needed if you are using something other than INCBIN. (To use my "bank crossing" feature, you have to assign several consecutive banks the same name. This must be done before any code is entered, otherwise it won't be detected properly.)
Quote:
Then only first 8kb will be included , the other half of the "example.bin" will be cut and removed. There will be no report of the overflow as well :\
It is then overwritten by other code (which can sometimes be useful). Something which I don't know if it is possible in normal NESASM or only in my version (I haven't checked), is you could make a macro to report INCBIN overflows if you want to (by using the FAIL command).

_________________
.


Top
 Profile  
 
PostPosted: Wed Nov 15, 2017 3:07 am 
Offline

Joined: Tue Apr 11, 2006 4:08 am
Posts: 248
Does NESASM3 have the ability to define 1KB CHR banks or do they always have 8KB?
Recently I tried to do test namco163 ROM and set the CHR banks. Unfortunately nothing works (Graphics are not displayed).

Code:
   .inesprg 8
   .ineschr 2
   .inesmap 19
   .inesmir 0


Code:

   .bank 16
   .org $0000

TileSet0:

   .incbin "demo.spr0"
   .org $0400
   .incbin "demo.spr1"
   .org $0800
   .incbin "demo.spr2"
   .org $0C00
   .incbin "demo.spr3"

   .org $1000
   .incbin "demo.spr0"
   .org $1400
   .incbin "demo.spr1"
   .org $1800
   .incbin "demo.spr2"
   .org $1C00
   .incbin "demo.spr3"

   .bank 17
   .org $0000

TileSet1:

   .incbin "demo.spr0"      ;1kb
   .org $0400
   .incbin "demo.spr1"
   .org $0800
   .incbin "demo.spr2"
   .org $0C00
   .incbin "demo.spr3"

   .org $1000
   .incbin "demo.spr0"
   .org $1400
   .incbin "demo.spr1"
   .org $1800
   .incbin "demo.spr2"
   .org $1C00
   .incbin "demo.spr3"


For now I do not know if in NESASM3 I have to set the addresses (.org) CHR banks every 1KB, or maybe they must always be 8KB size and only the mapper will notice and will automatically divide the banks by 1KB?

Code:
   .bank 16
   .org $0000

TileSet0:

   .incbin "demo.spr"
   .incbin "demo.chr"

   .bank 17
   .org $0000

TileSet1:

   .incbin "demo.spr"
   .incbin "demo.chr"


Top
 Profile  
 
PostPosted: Wed Nov 15, 2017 1:15 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1034
Here's two banks of what I did in Indivisible:
Code:
   .bank NUMPRGBANKS+6
   .org $0000
   
   .incbin "Data/ObjectCHR/ManoteThihaCHR/block7.chr"
   .incbin "Data/ObjectCHR/ManoteThihaCHR/block8.chr"
   
   .incbin "Data/ObjectCHR/ManoteThihaCHR/block9.chr"
HUNGRYGHOSTCHRSTART = MANOTETHIHACHRSTART+10
   .incbin "Data/ObjectCHR/HungryGhostCHR/block0.chr"
   

   
   
   .incbin "Data/ObjectCHR/HungryGhostCHR/block1.chr"
   .incbin "Data/ObjectCHR/HungryGhostCHR/block2.chr"
AHPCHRSTART = HUNGRYGHOSTCHRSTART+3
   .incbin "Data/ObjectCHR/AhpCHR/block0.chr"
   .incbin "Data/ObjectCHR/AhpCHR/block1.chr"
   
   .bank NUMPRGBANKS+7
   .org $0000
   
   .incbin "Data/ObjectCHR/AhpCHR/block2.chr"
BELUCHRSTART = AHPCHRSTART+3
   .incbin "Data/ObjectCHR/BeluCHR/block0.chr"
   
   .incbin "Data/ObjectCHR/BeluCHR/block1.chr"
   .incbin "Data/ObjectCHR/BeluCHR/block2.chr"
   
   
   
   
   
   .incbin "Data/ObjectCHR/BeluCHR/block3.chr"
   .incbin "Data/ObjectCHR/BeluCHR/block4.chr"
   .incbin "Data/ObjectCHR/BeluCHR/block5.chr"
   .incbin "Data/ObjectCHR/BeluCHR/block6.chr"

Each "block" is a 1KB file. You don't need the
"HUNGRYGHOSTCHRSTART = MANOTETHIHACHRSTART+10"
type lines, that's for the engine to access the right data.

edit: So basically: Banks are always 8KB, but you can totally just include eight 1KB files. (or four 2KB etc.) files. You only need to .org once. This is what my backgrounds looked like:
Code:
   .bank NUMPRGBANKS
   .org $0000
   
BACKGROUNDCHRSTART = 0

FONTCHRSTART = BACKGROUNDCHRSTART
   .incbin "Data/BackgroundCHR/font001.chr";2
   
TITLESCREENCHRSTART = FONTCHRSTART+2
   .incbin "Data/BackgroundCHR/Title_0.chr";2
LOGOCHRSTART = TITLESCREENCHRSTART+2
   .incbin "Data/BackgroundCHR/Title_1.chr";2
   .incbin "Data/BackgroundCHR/Title_2.chr";2

The mapper doesn't care what you do, really. I could combine eight 1KB files into one 8KB file and incbin that, and it wouldn't change what the NES or mapper sees.

Did you write the correct numbers for the data you wanted to the registers for the mapper? Is your reset routine in $E000-$FFFF in the last PRG bank?

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Wed Nov 15, 2017 2:48 pm 
Offline

Joined: Tue Apr 11, 2006 4:08 am
Posts: 248
I had a code reset at bank0. Now it's ok. Thanks :)

Code:

TileSet0:

   .incbin "demo.spr"
   .incbin "demo.chr"


   .bank 17
   .org $0000

TileSet1:


   .incbin "demo.spr"
   .incbin "demo.chr"


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: No registered users and 9 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