This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

NESASM Bank pseudo-op

NESASM Bank pseudo-op
by on (#127206)
Can someone explain to me how the NESASM .bank pseudo-op is supposed to work? I think it is overriding my .org statements: I have an .org $FF50 before my boot code, but NESASM is assembling it into an address around $9000. Do I have to explicitly write ".bank 1" to have it assemble correctly? Is there any way to just get rid of .bank statements and just use .org in NESASM? I'm using mapper 0.

Thanks for any help.

KKat
Re: NESASM Bank pseudo-op
by on (#127207)
NESASM forces you to organize your code in 8KB banks, whether or not you actually use bankswitching - thus, for a 32KB ROM, you must put ".bank 0" at $8000, ".bank 1" at $A000, ".bank 2" at $C000, and ".bank 3" at $E000.

If you don't want to mess with that, there are plenty of other 6502 assemblers which don't have this limitation.
Re: NESASM Bank pseudo-op
by on (#127209)
Is there any advantage to using banks? In your example, it seems like I could just set the starting addresses with .org without using banks, but I'm not sure how it would work if I was doing bank switching.

KKat
Re: NESASM Bank pseudo-op
by on (#127210)
In NESASM, if the code in one bank exceeds 8192 bytes, you MUST switch to another bank.
Re: NESASM Bank pseudo-op
by on (#127214)
KKat wrote:
Is there any advantage to using banks?

If you're not doing any bankswitching, no, but NESASM requires these breaks every 8KB.

Quote:
In your example, it seems like I could just set the starting addresses with .org without using banks

In other assemblers, yes.

Quote:
but I'm not sure how it would work if I was doing bank switching.

When bankswitching you must have a break of some kind, to reset the address to the beginning of the bank. How exactly this is done depends on the assembler and the mapper.
Re: NESASM Bank pseudo-op
by on (#127257)
Note also that banks in NESASM are also used to select the PRG ROM and CHR ROM. For example if there is 16K of PRG ROM, then the CHR ROM starts at bank 2.

tepples wrote:
In NESASM, if the code in one bank exceeds 8192 bytes, you MUST switch to another bank.
I have added a feature to overcome this limitation, though. If you use my version, it works as follows: If the current bank has a name, and the next bank has the same name, then when you reach the end of one bank it will automatically switch to the next bank and set the address correctly.
Re: NESASM Bank pseudo-op
by on (#127345)
KKat wrote:
Is there any way to just get rid of .bank statements and just use .org in NESASM? I'm using mapper 0.
You could write a macro to do it for you. (You could store such a thing in an include file, if you do not want to duplicate it for every program.)
Re: NESASM Bank pseudo-op
by on (#159430)
I have a problem with organizing mapper UNROM. The code works, but if you try to use such central banks like .bank3,4,5 This causes the glithed graphics (program in general does not see nametables).. Also, any code in these banks is skipped.

Is it correct?



Code:
   .inesprg 8
   .ineschr 0
   .inesmap 2
   .inesmir 0
   
   .bank 0
   .org $8000

;main code here

   .bank 1
   .org $A000

NameTable1:

   .incbin "demo.nam1"

NameTable2:

   .incbin "demo.nam2"

NameTable3:

   .incbin "demo.nam3"

NameTable4:

   .incbin "demo.nam4"

NameTable5:

   .incbin "demo.nam5"

   .bank 2
   .org $8000

   .bank 3
   .org $A000

   .bank 4
   .org $8000

   .bank 5
   .org $A000

   .bank 6
   .org $8000

   .bank 7
   .org $A000

   .bank 8
   .org $8000

   .bank 9
   .org $A000

   .bank 10
   .org $8000

   .bank 11
   .org $A000

   .bank 12
   .org $8000

   .bank 13
   .org $A000


   .bank 14
   .org $C000

TileSet:

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

   .bank 15
   .org $E000

   .org $FFFA

   .dw NMI
   .dw RESET
   .dw 0
Re: NESASM Bank pseudo-op
by on (#159438)
Code:
.inesprg 8

This line says that you only have 8 x 16k PRG banks.

Edit: ignore me, this part was correct, I guess.
Re: NESASM Bank pseudo-op
by on (#159439)
Which is consistent with NESASM banks from 0 to 15, as NESASM's 8K bank numbers are for N108/MMC3/FME-7.
Re: NESASM Bank pseudo-op
by on (#159440)
rainwarrior wrote:
This line says that you only have 8 x 16k PRG banks.

Isn't this correct, considering that he's targeting UNROM and using .bank to create 16 x 8KB banks?
Re: NESASM Bank pseudo-op
by on (#159441)
Oh, sorry, I forgot that .bank in NESASM is 8k, and .inesprg is 16k. I thought they were both 16k. Pls ignore.