Comments (15)
Welcome to GitHub. We typically put code in monospaced font blocks, like this:
std::cout << "hello world\n";
You can find that tool here as you are composing your post:
and use the Preview tab to see what it looks like before posting.
from asar.
While useful in theory, it's kinda tricky to implement in practice.
org $008000
lda Mylabel,x
pc:
if pc == $008003
Mylabel = $018000
else
Mylabel = $008000
endif
If Mylabel is in the same bank as the LDA, it will be .w, and pc will be $008003 at the if. But then Mylabel is $018000.
If Mylabel is not in the same bank as the LDA, it will be .l, and pc will be $008004 at the if. But then Mylabel is $008000.
We allow some operations on pc, but there are also several restrictions, to avoid the aforementioned paradox.
from asar.
Thanks for the reply, i didn't knew that.
I search for a way to detect if the binary i want to include fits current bank, otherwise switch the bank and inlude it in next.
from asar.
Can you give us a bit more context on what you're trying to accomplish and what you're working with? Maybe we can offer workarounds. For example, are you able to use freedata/freecode? From what I remember, freedata tries to find the first free space in the ROM large enough to hold your data and only moves stuff into an empty bank when it doesn't fit into a prior, non-empty one. Though I'm not sure if that provides enough flexibility for you, or if you can even use freedata in the first place. Either way, if you can share some more details, we might be able to propose workarounds.
from asar.
from asar.
Well, there's still a lot of unknowns here. Are you trying to patch an existing ROM, or creating a homebrew? What mapper are you using? LoROM? HiROM? Something else entirely? Are you using freedata for automatic space allocation, or using org for manual placement? All of these things matter.
I can't give you a solution that's guaranteed to work without enough context. I'll just assume you're working on a homebrew, you know what mapper you're using (and by extension, how much space there is in a bank), and you are in control of where to begin with data insertion. If so, I'm pretty sure you can cook up a solution that does pretty much what you want it to do using the filesize()
, macros and defines.
from asar.
from asar.
It IS relevant. If you have control over insert location, then you can keep track of PC yourself very easily and don't need a built-in function for.
A simple "get current PC" function is unlikely to make it to Asar without some major compromises, due to issues already noted by Alcaro above. It can only ever work reliably in very specific circumstances.
from asar.
Example to understand my problem:
;we are somewhere at e9 bank
label_e9: ;it knows pc, but we can only use it like snes code dw label_e9, not asar code
incbin "file.bin" ;we know it's length, does it fit in current bank?
I don't want "get current pc" function, i want
to add labels with pc, or do pc>>16 to get it's bank.
from asar.
i need to read pc position.
I don't want "get current pc" function
So which one is it now? 🤷♂️
to add labels with pc, or do pc>>16 to get it's bank.
Both of those things are already possible in Asar, just not in the contexts you want (like if statements). And as mentioned above, functionality like that isn't likely to be added to Asar anytime soon, due to complexity and caveats already mentioned above, so if it's something you need right now, you HAVE to use a workaround. Either that, or completely change the approach of what you're doing.
Going ahead and closing the issue now, since we already explained our reasoning and provided workaround, so I don't think there's anything left for us to do here at this time.
from asar.
You didn't answer the riddle:
macro put()
incbin "frame1.bin"
incbin "frame2.bin"
endmacro
Find a way to know if some of the includes would cause bank overflow.
Make EVERY approach you want.
Use ANY workaround.
I accept the "asar doesn't support this", i don't accept the "use another way to do it". There is no other way since you can't do math with labels.
from asar.
do you have any code in the same bank, before the frame data? or can you put the frame data right at the start of the bank?
from asar.
do you have any code in the same bank, before the frame data? or can you put the frame data right at the start of the bank?
I put data in the start of the bank, but there are too many that overflow many banks.
from asar.
if you can put it right at the start, then you can keep track of the pc with a define, like this:
!curpc #= $e98000
macro putfile(name,label)
if !curpc+filesize("<name>")&$ff0000 != !curpc&$ff0000 ; if we would overflow the bank,
!curpc #= !curpc&$ff0000+$018000 ; go to the start of the next bank
org !curpc
endif
<label>: incbin "<name>"
!curpc #= !curpc+filesize("<name>")
endmacro
%putfile("frame1.bin",label_frame1)
%putfile("frame2.bin",label_frame2) ; etc
(the "go to the next bank" part here assumes lorom. you can change $018000 to $010000 for hirom i think.)
from asar.
Correct, that's what i will do. Thanks.
from asar.
Related Issues (20)
- org Label in freespace yields too small rats tags HOT 1
- datasize fails when used in assert or print before label is defined HOT 6
- Finding freespace beyond on the end of the ROM only works if the value is 0 HOT 4
- Allow branches to take full addresses HOT 4
- asar_getlabelval throws C++ exception for missing label
- Please document deprecation of features HOT 4
- Segfault with invalid syntax in an assert HOT 2
- defining a label on the same line as an `if` statement is sometimes broken HOT 3
- arch superfx is haunted HOT 1
- MVP and MVN documentation HOT 6
- [Asar2] Phantom Error when using array indices HOT 1
- How do I actually compile a ROM, not a patch? HOT 2
- `includeonce` breaks on some equivalent paths HOT 2
- Mapping mode detection is always lorom
- "check bankcross off" breaks "freedata" on fullsa1rom
- Trailing comma after `db` statement lacks helpful error HOT 3
- if statement can no longer have a bracket on same line HOT 3
- Freespace finder is broken when RATS tags cross banks HOT 1
- [Asar2] Three letter variable names are not accepted anymore HOT 5
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 asar.