Jump to content

Creating bank switched cartridges with gcc

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 = .
 .data          0x000000000000a000        0x0 persistent/utils.o
 .data          0x000000000000a000        0x2 persistent/trampolines.o
                0x000000000000a000                bankbase
 .data          0x000000000000a002        0x0 persistent/vdp.o
 .data          0x000000000000a002        0x0 bank0/main.o
 .data          0x000000000000a002        0x0 bank1/functions1.o
 .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 = .
 .bss           0x000000000000a002        0x0 persistent/utils.o
 .bss           0x000000000000a002        0x2 persistent/trampolines.o
                0x000000000000a002                currentbank
 .bss           0x000000000000a004        0x2 persistent/vdp.o
                0x000000000000a004                current_line
 .bss           0x000000000000a006        0x0 bank0/main.o
 .bss           0x000000000000a006        0x0 bank1/functions1.o
 .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.

Share this post

Link to post
Share on other sites

Thanks Chue and Tursi! I think I've worked out all the kinks. Works on Real Iron! Works on JS99'er with 32K expansion turned off too. I'm excited.

Edited by mindlord
  • Like 1

Share this post

Link to post
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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...