Working with multiple banks

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Working with multiple banks
by on (#175021)
I recently switched from XKAS to WLADX (thanks for the tip Revenant!). I am having trouble with the .BANK directive. I have a bunch of stuff in the first bank using
Code:
.BANK 0
. However when I try to put stuff in the second bank with
Code:
.BANK 1
nothing is put there in assembly i.e. from $10000 to the end of file is completely empty. I have searched all over but can't find a single WLA asm file online that uses multiple banks; I'm starting to think I am the only person suffering with this problem.

I have provided the asm file (scrollsnes.asm). If anyone could look at it and provide insight I would be very grateful.
Re: Working with multiple banks
by on (#175027)
AzimuthFE wrote:
I have searched all over but can't find a single WLA asm file online that uses multiple banks

Here's the first example that comes to mind. :wink:

AzimuthFE wrote:
I have provided the asm file (scrollsnes.asm). If anyone could look at it and provide insight I would be very grateful.

Your mistake is using .ASM and .ENDASM in the wrong fashion. Whatever you put after .ENDASM will be completely ignored by WLA, just as if it was commented out. (The .ASM directive, on the other hand, tells WLA to continue assembling your code/directives. IOW, .ENDASM equals /*, and .ASM equals */).

Also, your .DB and .INCBIN directives need dots. :)

This is how your file (scrollsnes.asm) should look like so WLA assembles it just fine:

Code:
.SNESHEADER
ID            "ABCD"
NAME         "SCROLLTEST"
HIROM
FASTROM
CARTRIDGETYPE   $02
ROMSIZE         $0c
SRAMSIZE      $03
COUNTRY         $00
LICENSEECODE   $00
VERSION         $00
.ENDSNES


.SNESNATIVEVECTOR
COP    $8000
BRK    $8000
ABORT  $8000
NMI    $8000
UNUSED $0000
IRQ    $8000
.ENDNATIVEVECTOR

.SNESEMUVECTOR
COP    $8000
UNUSED $0000
ABORT  $8000
NMI    $8000
RESET  reset
IRQBRK $8000
.ENDEMUVECTOR

.ENUM $0000
INIDISP      db
OBSEL      db
OAMADD:      dw
OAMDATA      db
BGMODE      db
MOSAIC      db
BG1SC      db
BG2SC      db
BG3SC      db
BG4SC      db
BG12NBA      db
BG34NBA      db
BG1HOFS:   dw
BG1VOFS:   dw
BG2HOFS:   dw
BG2VOFS:   dw
BG3HOFS:   dw
BG3VOFS:   dw
BG4HOFS:   dw
BG4VOFS:   dw
VMAIN      db
VMADD:      dw
VMDATA:      dw
M7SEL      db
m7a         db
m7b         db
m7c         db
m7d         db
m7x         db
m7y         db
CGADD      db
CGDATA      db
W12SEL      db
W34SEL      db
WOBJSEL      db
WH0         db
WH1         db
WH2         db
WH3         db
WBGLOG      db
WOBJLOG      db
TM         db
TS         db
TMW         db
TSW         db
CGWSEL      db
CDADSUB      db
COLDATA      db
SETINI      db
MPYL      db
MPYM      db
MPYH      db
SLHV      db
OAMDATAREAD   db
VMDATAREAD:   dw
CGDATAREAD   db
OPHCT      db
OPHCV      db
STAT77      db
STAT78      db
APUI00      db
APUI01      db
APUI02      db
APUI03      db
WMDATA      db
WMADDL      db
WMADDM      db
WMADDH      db
NMITIMEN   db
WRIO      db
WRMPYA      db
WRMPYH      db
WRDIVL      db
WRDIVH      db
WRDIVB      db
HTIMEL      db
HTIMEH      db
VTIMEL      db
VTIMEH      db
MDMAEN      db
HDMAEN      db
MEMSEL      db
RDNMI      db
TIMEUP      db
HVBJOY      db
RDIO      db
RDDIVL      db
RDDIVH      db
RDMPYL      db
RDMPYH      db
JOY1:      dw
JOY2:      dw
JOY3:      dw
JOY4:      dw
.ENDE

.ENUM   $0100
ROM_CPY_PTR   ds 3
.ENDE

.MEMORYMAP             ; Tell WLA that the SNES has ROM at locations 0000-$FFFF in every bank
SLOTSIZE $10000        ; and that this area is $10000 bytes in size.
DEFAULTSLOT 0          ; There is only a single slot in SNES, other consoles
SLOT 0 $0000           ;   may have more slots per bank.
.ENDME

.ROMBANKSIZE $10000    ; Every ROM bank is 64 KBytes in size, also necessary.
.ROMBANKS $40          ; 32Mbit -- Tell WLA to use 64 ROM banks.
.DEFINE HEADER_OFF $8000

.BANK 0
.ORG $8000
reset:
   sei
   clc
   xce
   sep   #$30
   lda   #$8f
   sta   $2100
   stz   $2101
   ldx   #$05
firstinit:
   stz   $2100,x
   inx
   cpx   #$0d
   bne   firstinit
secondinit:
   stz   $2100,x
   stz   $2100,x
   inx
   cpx   #$15
   bne   secondinit
   lda   #$80
   sta   $2115
   stz   $2116
   stz   $2117
   stz   $211a
   lda   #$01
   stz   $211b
   sta   $211b
   stz   $211e
   sta   $211e
   stz   $211c
   stz   $211c
   stz   $211d
   stz   $211d
   stz   $211f
   stz   $211f
   stz   $2120
   stz   $2120
   ldx   #$21
thirdinit:
   stz   $2100,x
   inx
   cpx   #$30
   bne   thirdinit
   lda   #$30
   sta   $2130
   stz   $2131
   lda   #$e0
   sta   $2132
   stz   $2133
   stz   $4200
   lda   #$ff
   sta   $4201
   lda   #$02
fourthinit
   stz   $4200,x
   inx
   cpx   #$0e
   bne   fourthinit

.BANK 1 SLOT 0
.ORG $8000
.db   $41
openinggraphics:
.INCBIN   "scrsnes/genersnes"
openingmeta:
.INCBIN   "scrsnes/metatiles"
openingmetamap:
.INCBIN   "scrsnes/metatilemap"


Note that I completely deleted the unnecessary .ENDASM/.ASM directives. :)
Re: Working with multiple banks
by on (#175159)
Sorry for the late reply. I really appreciate you taking the time to look at it. I'm sorry it wasn't something more taxing. I just had it in my mind that "asm goes in asm directive". Anyway, it works now so thanks again.