Jump to content

The AtariAge Forum is undergoing a major upgrade today.  The forum is currently in read-only mode except for the Announcements Forum.  Please read this important post!


Creating bank switched cartridges with gcc

gcc cartridge bankswitching

101 replies to this topic

#101 chue OFFLINE  



  • 391 posts

Posted Fri Jun 16, 2017 6:29 AM

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.

#102 mindlord OFFLINE  


    Star Raider

  • 89 posts

Posted Fri Jun 16, 2017 8:01 PM

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, Sun Jun 18, 2017 9:58 AM.

  • Tursi likes this

Also tagged with one or more of these keywords: gcc, cartridge, bankswitching

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users