Jump to content
Karl G

Conditional compilation?

Recommended Posts

I wasn't able to find anything in the docs, or discussion in the forum, but is there a way to do conditional compilation in bB? Something that is equivalent of "ifconst" in asm?

Share this post


Link to post
Share on other sites

Nope, but you can break out to assembly and do it yourself...

 

 asm
 ifconst OFFICIAL_RELEASE
end
 rem some conditional code here
 asm
 endif
end

I added "#ifconst" "#else" and "#endif" to 7800basic. Nice to be able to skip the "asm" wrappers.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks! Is there any chance of this or some of your 7800basic enhancements getting backported to bB eventually? I'm also thinking of your TIA sound driver.

 

 

Nope, but you can break out to assembly and do it yourself...

 asm
 ifconst OFFICIAL_RELEASE
end
 rem some conditional code here
 asm
 endif
end
I added "#ifconst" "#else" and "#endif" to 7800basic. Nice to be able to skip the "asm" wrappers.

 

Share this post


Link to post
Share on other sites

The #ifconst, #else, #endif would be easy enough, so I may do that when I next have my hands in it. I've back ported bug-fixes as I've run across them.

 

I'm not really sure there's a lot more in 7800basic that would be useful in bB; the trade-offs for a machine with 4k address space and 128 bytes of RAM are fairly different than one with 64k address space and 4k of RAM.

 

The TIA SFX driver in particular doesn't pack the sound data into ROM as efficiently as it might, in part because the format is extendable to pokey.

Share this post


Link to post
Share on other sites

Why can't I get this to work, I get a bunch of errors with 2600basic_variable_redefs.h

This compiles but doesn't work as it should

 

 asm

PFRESOLUTION = 22

end



 asm

 if PFRESOLUTION == 22

distance = 132 ;66 for two bytes, 132 for four bytes etc.

bytesInColumn = 4

increments = 2

padding = 1 ; 1 or 0



 endif

end



 asm

 if PFRESOLUTION == 11

distance = 66 ;66 for two bytes, 132 for four bytes etc.

bytesInColumn = 2

increments = 1

padding = 0 ; 1 or 0



 endif

end

and this compiles and work correctly

 asm

PFRESOLUTION = 22

end



 asm

 if PFRESOLUTION == 22

end

 const distance = 132 ;66 for two bytes, 132 for four bytes etc.

 const bytesInColumn = 4

 const increments = 2

 const padding = 1 ; 1 or 0

 asm

 endif

end

but if I add more conditions like that I get a bunch of old value new value/value mismatch errors

 asm

 if PFRESOLUTION == 22

end

 const distance = 132 ;66 for two bytes, 132 for four bytes etc.

 const bytesInColumn = 4

 const increments = 2

 const padding = 1 ; 1 or 0

 asm

 endif

end



 asm

 if PFRESOLUTION == 11

end

 const distance = 66 ;66 for two bytes, 132 for four bytes etc.

 const bytesInColumn = 2

 const increments = 1

 const padding = 0 ; 1 or 0

 asm

 endif

end

 

Share this post


Link to post
Share on other sites

Get rid of the C-style double equal sign operator, and see if that works. 

Share this post


Link to post
Share on other sites

To be clear, a single equal sign instead of two, not none at all. 

Share this post


Link to post
Share on other sites

If you post the whole source or send it to me, I can take a look at it tomorrow. 

Share this post


Link to post
Share on other sites

It's the bB const statements. The bB compiler operates at a higher level than assembly, so it doesn't know about your asm conditionals. It processes both sets of constants in the different blocks, and then it sticks those contradictory definitions into 2600basic_variable_redefs.h.

 

Solution 1 - don't use differing constants in each block.

Solution 2 - use assembly constants. If you need to reference the constants in bB commands, then you need to tell bB they're constants with a self-referencing constant definition, like "const bytesInColumn=bytesInColumn"

 

I honestly didn't consider this before, but it's a wider problem for any command that saves intermediate state in the compiler - like "set". I'll need to add some warnings into the 7800basic manual. (these aren't official bB commands, no updates are needed for bB docs)

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

I did think that it was because the bB code was compiled first and ignored the conditionals, but I didn't know you had to reference an assembly constant like that, thanks! that worked like a charm.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...