Jump to content
IGNORED

Creating bank switched cartridges with gcc


TheMole

Recommended Posts

So how does global variables work with bank switching? If I put them in the same space as the trampolines and cart headers I have to declare them 4 times with four different symbols.

 

As Tursi said just declare them once. By definition, variables change and therefore are stored in RAM. You shouldn't be bank switching them. Bankswitching is only for ROM content.

 

Is there an easy way to see how much RAM is being used ...?

 

One of the build output files is called "link.map" and contains the ROM/ RAM layout. Look for the ".data" and ".bss" sections, which will show your RAM usage. Here is a sample from the bankswitch project that I uploaded earlier in this thread:

.data           0x000000000000a000        0x2 load address 0x000000000000c05e
                0x000000000000a000                _data = .
 persistent/*.o(.data)
 .data          0x000000000000a000        0x0 persistent/utils.o
 .data          0x000000000000a000        0x2 persistent/trampolines.o
                0x000000000000a000                bankbase
 .data          0x000000000000a002        0x0 persistent/vdp.o
 bank0/*.o(.data)
 .data          0x000000000000a002        0x0 bank0/main.o
 bank1/*.o(.data)
 .data          0x000000000000a002        0x0 bank1/functions1.o
 bank2/*.o(.data)
 .data          0x000000000000a002        0x0 bank2/functions2.o
                0x000000000000a002                _data_end = .
 .data          0x000000000000a002        0x0 bank0-head/cart_header.o
 .data          0x000000000000a002        0x0 bank0-head/crt0.o
 .data          0x000000000000a002        0x0 bank1-head/cart_header.o
 .data          0x000000000000a002        0x0 bank1-head/crt0.o
 .data          0x000000000000a002        0x0 bank2-head/cart_header.o
 .data          0x000000000000a002        0x0 bank2-head/crt0.o
 .data          0x000000000000a002        0x0 bank3-head/cart_header.o
 .data          0x000000000000a002        0x0 bank3-head/crt0.o
.bss            0x000000000000a002        0x4 load address 0x000000000000c060
                0x000000000000a002                _bss = .
 persistent/*.o(.bss)
 .bss           0x000000000000a002        0x0 persistent/utils.o
 .bss           0x000000000000a002        0x2 persistent/trampolines.o
                0x000000000000a002                currentbank
 .bss           0x000000000000a004        0x2 persistent/vdp.o
                0x000000000000a004                current_line
 bank0/*.o(.bss)
 .bss           0x000000000000a006        0x0 bank0/main.o
 bank1/*.o(.bss)
 .bss           0x000000000000a006        0x0 bank1/functions1.o
 bank2/*.o(.bss)
 .bss           0x000000000000a006        0x0 bank2/functions2.o
                0x000000000000a006                _bss_end = .
 .bss           0x000000000000a006        0x0 bank0-head/cart_header.o
 .bss           0x000000000000a006        0x0 bank0-head/crt0.o
 .bss           0x000000000000a006        0x0 bank1-head/cart_header.o
 .bss           0x000000000000a006        0x0 bank1-head/crt0.o
 .bss           0x000000000000a006        0x0 bank2-head/cart_header.o
 .bss           0x000000000000a006        0x0 bank2-head/crt0.o
 .bss           0x000000000000a006        0x0 bank3-head/cart_header.o
 .bss           0x000000000000a006        0x0 bank3-head/crt0.o

As you can see it starts at a000 and ends at a006, so the project uses that range for RAM/ variables.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...