Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - devkitSMS newbie help :)

Reply to topic
Author Message
  • Joined: 27 Apr 2021
  • Posts: 2
Reply with quote
devkitSMS newbie help :)
Post Posted: Thu May 06, 2021 9:24 am
Hi everybody.

I recently started to make my homebrews for SMS with the devkitSMS.
I have trouble using datas, banks, etc..
Please note that I'm a novice with master system architecture :)
What I know is that it's all about 16k banks :
- 2 banks max for code
- X banks for data

My question is about the buidling of the ROM and the banking system :
Actually I use this commandlines to build my project :

/* gfx is my directory with all the psgcompr, tilemaps, etc... */
assets2bank gfx

/* output is bank2.c and bank2.h that I build with this command */
sdcc -mz80 --peep-file peep-rules.txt -c src/bank2.c -o out/bank2.rel --constseg BANK2 --no-std-crt0


/* I compile all my c files like this */
sdcc -mz80 --peep-file peep-rules.txt -c sourcefile.c -o sourcefile.rel --no-std-crt0

/* Then I link */
sdcc -mz80 --peep-file peep-rules.txt -o out/main.ihx --data-loc 0xC000 --no-std-crt0 -Wl-b_BANK2=0x8000  rel/crt0_sms.rel lib/SMSlib.lib *.rel out/bank2.rel

/* Finally */
makesms out/main.ihx out/main.sms


The final output is :

*** sverx's makesms converter ***
Info: 18528 bytes used/16384 total [113.09%] - size of output ROM is 16 KB
Info: SEGA header found, checksum updated


Juste for saying : At the beginning, with only 16k code+data and no banking options, my project was okay and run perfectly on every emulators :)

So there is clearly something I do wrong... I expected to have a 32k ROM with 1 bank of code and 1 bank of data but I got a 16k rom...
Any help ?
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2943
Reply with quote
Post Posted: Thu May 06, 2021 9:48 am
if you don't really plan to need more than 32 KB for code, you can choose the easy route to do NOT use banked code (but sure you can bank your assets)

Basically you compile all your sources and link them with no special instructions to the linker, then you add your assets from BANK2 on and you link all together using -Wl-b_BANKn=0x8000 for all your data banks.

example: say your sources are main.c, player.c and enemies.c - you compile them:

sdcc -mz80 --peep-file peep-rules.txt -c main.c
sdcc -mz80 --peep-file peep-rules.txt -c player.c
sdcc -mz80 --peep-file peep-rules.txt -c enemies.c


then you link everthing (let's pretend you have 3 data banks):

sdcc -mz80 -o output.ihx --data-loc 0xC000 --no-std-crt0 -Wl-b_BANK2=0x8000 -Wl-b_BANK3=0x8000 -Wl-b_BANK4=0x8000 crt0_sms.rel SMSlib.lib main.rel player.rel enemies.rel bank2.rel bank3.rel bank4.rel


finally you have to use the ihx2sms tool (the makesms tool works for the banked code) on the output.ihx file to get your .sms file.

I hope it helps. Let me know if something isn't clear.

edit: in case you want to fit both code and data into 32 KB, you just link your assets2banks generated file (say it's called bank2.rel anyway) with no instructions to the linker as in:

sdcc -mz80 -o output.ihx --data-loc 0xC000 --no-std-crt0 crt0_sms.rel SMSlib.lib main.rel player.rel enemies.rel bank2.rel


(you have to use ihx2sms in this case too)
  View user's profile Send private message Visit poster's website
  • Joined: 27 Apr 2021
  • Posts: 2
Reply with quote
Post Posted: Thu May 06, 2021 11:48 am
Hi Sverx.

I understood perfectly and now it works nice :)

Thank for the time :)
screen1.png (47.22 KB)
screen1.png

  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2943
Reply with quote
Post Posted: Thu May 06, 2021 2:45 pm
It seems great! I'm looking forward to see it released :)
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!