Comments (22)
first: ihx2sms
doesn't support banked code, so you can't use that tool and you have to rely on makesms
instead, which supports banked data and code and uses virtual addresses
the easiest way to have banked code and banked data in your program is to have whole banks contain either code or data, even if sometimes this requires a bit of waste
so if your banked code uses, for instance, 3 banks, you may want to call them BANK1, BANK2 and BANK3
then your banked data will start from BANK4, say you also have BANK5 and BANK6
then you will link those banks using:
-Wl-b_CODEBANK1=0x14000 -Wl-b_CODEBANK2=0x24000 -Wl-b_CODEBANK3=0x34000 -Wl-b_DATABANK4=0x48000 -Wl-b_DATABANK5=0x58000 -Wl-b_DATABANK6=0x68000
that is: code banks will be at address x4000
and data banks at address x8000
(please note that this is hexadecimal so DATABANK10 will be at A8000
not at 108000
)
I hope this helps!
from devkitsms.
did you try something easy like:
sdcc -c -mz80 --codeseg BANK1 bank1.c
sdcc -c -mz80 --codeseg BANK2 bank2.c
sdcc -c -mz80 --codeseg BANK3 bank3.c
sdcc -c -mz80 --constseg BANK4 bank4.c
sdcc -c -mz80 --constseg BANK5 bank5.c
sdcc -o file.ihx -mz80 --no-std-crt0 --data-loc 0xC000 -Wl-b_BANK1=0x14000 -Wl-b_BANK2=0x24000 -Wl-b_BANK3=0x34000 -Wl-b_BANK4=0x48000 Wl-b_BANK5=0x58000 crt0b_sms.rel SMSlib.lib main.rel bank1.rel bank2.rel bank3.rel bank4.rel bank5.rel
this is what I do in my code and it works fine.
from devkitsms.
Also don't let the SMS ROM file fool you. The banks are ordered there but their address is in no way indicative of at what address the Z80 will see them. So code can be at ROM address 0x8000 (ROM bank 2) but will be mapped at Z80 address 0x4000 because that's what mappers do 😄
from devkitsms.
4, of course.
If you use assets2banks tool, you get a bunch of defines that you can use and not even worry about what's the actual value.
Please check that. It's the fastest and easiest way to handle assets (data).
from devkitsms.
assets2banks.py assets --firstbank=4 --compile --singleheader
this will create your rel files directly, starting from bank4.rel, and will create the assets2banks.h file with all the defines you need
from devkitsms.
If everything is done correctly, code mapping should be transparent - you shouldn't need that.
If it wasn't working when the __banked keyword was present, it is likely because the declaration of the function was missing that part. What I mean is that you need to have a .h file that declares that function as banked and you have to include that .h file in your main, or if you don't want a separate .h file, you have to anyway declare the banked function in your main.c as in
void functionBank1(void) __banked;
from devkitsms.
you can ignore that SDCC message, it's a leftover debug info, I have a few of them too and still everything works
from devkitsms.
please try with something very simple like this example here, you'll see the basics of transparent code banking at work
from devkitsms.
I never added SMS_mapCODEBank()
in the first place, as that wasn't needed at all.
If you use transparent code banking you don't need to do anything beside declaring the banked code as banked.
from devkitsms.
I'm not sure what you want to get here, I wouldn't use both CODEBANK2 and DATABANK2...
anyway the main problem I see here is the linking: you need to specify virtual addresses for the data banks too so it's
-Wl-b_DATABANK2=0x38000 -Wl-b_DATABANK3=0x48000
and you can see why I would use DATABANK3 and DATABANK4 instead.
... oh, wait, unless you want to use bank 2 for BOTH code and data because why not? So you need correct virtual addresses anyway:
-Wl-b_DATABANK2=0x28000 -Wl-b_DATABANK3=0x38000
from devkitsms.
Ah... Thanks!
I want to use both code and data banks.
I will try to use this "-Wl-b_DATABANK2=0x28000 -Wl-b_DATABANK3=0x38000"
from devkitsms.
Hmm.... I could not locate data banks properly...
Could you please tell me the proper way to use both data and code banks ?
I think makesms does not support data bank like ihx2sms does...
from devkitsms.
mmm. Gave up.
>-Wl-b_CODEBANK1=0x14000 -Wl-b_CODEBANK2=0x24000 -Wl-b_CODEBANK3=0x34000 -Wl-b_DATABANK4=0x48000 -Wl-b_DATABANK5=0x58000 -Wl-b_DATABANK6=0x68000
Why the makesms places CODEBANK2 to 8000H in sms file? I think 8000H is ROM/RAM mapper slot 2.
And, makesms places CODEBANK1 to 04000H in sms file. 04000H is #0 of mapper slot 1.
But, SDCC linker treats CODEBANK1 as 14000H, so SDCC changes bank no to #1 of mapper slot 1 when invoking function on the CODEBANK1.
from devkitsms.
did you try something easy like:
oops, i will try.
from devkitsms.
When I use BANK4 data, which number should I specify to the SMS_mapROMBank( xxx ) API ?
from devkitsms.
Bingo! Thank you!
I could run my program, but..... only when I removed "__banked" magic word from a function. Is that okay...?
So, I must write the following codes... ( SMS_mapCODEBank() is my custom API )
SMS_mapCODEBank(1); SMS_mapROMBank(4); functionBank1(); // Using BANK4 data SMS_mapCODEBank(2); SMS_mapROMBank(5); functionBank2(); // Using BANK5 data
from devkitsms.
Hmm... Failed... I placed "__banked" keyword to both declaration and function body... mmm...
from devkitsms.
And do you know what means the following compiler warning message ? Can I skip this message?
source.c:17: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes 'b_fuctionBank1 = 1'
from devkitsms.
Thank you so much!
EDIT: OMG.. What is "SMS_EMBED_SEGA_ROM_HEADER_16KB" ...? Do I need to specify this instead of normal header?
My demo program is here.
https://twitter.com/SNDR_SNDL/status/1381956874287808520
from devkitsms.
You might want to use that or you might place the regular header on the source code that goes to bank 1 - I would use that _16KB as it's just easier.
from devkitsms.
So sorry.
SMS_mapCODEBank() is deleted on recent version ?
from devkitsms.
Oops.. so sorry. It is my fault...
from devkitsms.
Related Issues (20)
- Can't find sdcc 3.9.5 HOT 4
- SMS_readPaddle() never returns if the paddle is disconnected HOT 5
- Interrupt and VDP processing HOT 8
- 32bits variables HOT 2
- Using PSGlib with banked code HOT 4
- Macros to save/restore the bank mapped to slot2? HOT 9
- Ability to install a vblank handler HOT 7
- Need clear vram on startup HOT 3
- SG-1000 ROMs on SC-3000 - Sega standard. HOT 59
- Adding examples to this repo HOT 6
- issue with compressed songs spawning multiple banks HOT 3
- New Unsafe and Vertical Orientation Functions HOT 17
- SG/SC -> SG_byte_brief_array_to_VDP_data HOT 1
- SMS_saveROMBank() implementation in SMSLib.h makes it only usable in the same scope as SMS_restoreBank() HOT 9
- PSGLib - Allow to set volume attenuation on SFX HOT 4
- crt0_sg.s incorrect initialization of I/O chip HOT 1
- SC-3000 Cassette Support HOT 6
- assets2banks with files > 16kb in size HOT 4
- SMS_setTileatXY HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devkitsms.