Code Monkey home page Code Monkey logo

Comments (15)

jeffythedragonslayer avatar jeffythedragonslayer commented on July 16, 2024

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:

image

and use the Preview tab to see what it looks like before posting.

from asar.

Alcaro avatar Alcaro commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

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.

RPGHacker avatar RPGHacker commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

from asar.

RPGHacker avatar RPGHacker commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

from asar.

RPGHacker avatar RPGHacker commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

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.

RPGHacker avatar RPGHacker commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

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.

randomdude999 avatar randomdude999 commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

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.

randomdude999 avatar randomdude999 commented on July 16, 2024

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.

gizaha avatar gizaha commented on July 16, 2024

Correct, that's what i will do. Thanks.

from asar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.