+Random Terrain Posted August 30, 2011 Share Posted August 30, 2011 If I want to reuse bits in other places in my program (using different aliases), how do I do that using DEF? The following will not work: def Bit_Debounce_Fire=BitOp_All_Purpose_01{1} def Bit_Debounce_Joystick=BitOp_All_Purpose_01{1} When I was using DIM only, I could reuse bits with different aliases all I wanted as long as I used the correct bit (for example, BitOp_Debounce_Joystick{1}). Is there a way to use more than one alias with the same bit using DEF or is the only solution to use DIM? Thanks. Quote Link to comment Share on other sites More sharing options...
ScumSoft Posted August 30, 2011 Share Posted August 30, 2011 (edited) [edit]Sorry for the unclear explanation, that is what I get for posting at 4am on my ipod. def is nothing more than a double reference as a convenience to the dim statement, but is used differently. You can say: dim Apple = a dim Banana = b def Pear=Apple whenever you say Pear = 5, what gets said to the compiler is Apple = 5 (not pear), it's a convenience thing to reference the same variable by different names. A work around for your problem without changing compiler version would be to reference the reference: def Bit_Debounce_Fire=BitOp_All_Purpose_01{1} def Bit_Debounce_Joystick=BitOp_All_Purpose_01{1} rem becomes def Bit_Debounce_Fire=BitOp_All_Purpose_01{1} def Bit_Debounce_Joystick=Bit_Debounce_Fire That's what I meant in a VERY abstract sort of way. Edited August 31, 2011 by ScumSoft Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 30, 2011 Author Share Posted August 30, 2011 (edited) Def is the same as saying X points to Y, where as Dim says for every use of X treat it as Y. So Dim Apple = a is saying when apple is used modify a instead. and Def Banana=Apple{7} is saying when I say banana, what I really mean is Apple{7} so use that Now when you declare a dim you can have multiple aliases for a single variable, but when you declare the use of define(def) your telling it to replace every usage of X with Y and if you also want it to replace Z with Y it wont work since its been assigned to replace X instead. So to fix your issue assign x=Banana{7} and y=x I'm not sure I understand your last line. I've been doing stuff like this for a while without DEF: rem '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' rem ' rem ' All-purpose bits for various jobs. rem ' rem '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' rem ' dim BitOp_All_Purpose_01 = t dim BitOp0_Debounce_Reset = t dim BitOp0_Fingernail_Soup = t dim BitOp4_Toggle_Screen = t dim BitOp5_B_Direction_X = t dim BitOp6_B_Direction_Y = t dim BitOp7_Missile0_Moving = t Examples: if BitOp0_Debounce_Reset{0} then blah blah blah if BitOp0_Fingernail_Soup{0} then blah blah blah if BitOp4_Toggle_Screen{4} then blah blah blah if BitOp7_Missile0_Moving{7} then blah blah blah So, unless the last line in your post means something else, if you want to have more than one meaningful alias in other places in a program, you need to use DIM. DEF is only useful for replacing one logical name with one unique string. Multiple uses of the same string is not allowed. Edited August 30, 2011 by Random Terrain Quote Link to comment Share on other sites More sharing options...
RevEng Posted August 30, 2011 Share Posted August 30, 2011 If I want to reuse bits in other places in my program (using different aliases), how do I do that using DEF? The following will not work... It works for me, so you must be running into some other issue. I put together the following minimal program, and it compiled fine, and produced the expected assembly code... dim BitOp_All_Purpose_01=a def Bit_Debounce_Fire=BitOp_All_Purpose_01{1} def Bit_Debounce_Joystick=BitOp_All_Purpose_01{1} if Bit_Debounce_Fire then goto done if Bit_Debounce_Joystick then goto done done Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 30, 2011 Author Share Posted August 30, 2011 It works for me, so you must be running into some other issue. I put together the following minimal program, and it compiled fine, and produced the expected assembly code... dim BitOp_All_Purpose_01=a def Bit_Debounce_Fire=BitOp_All_Purpose_01{1} def Bit_Debounce_Joystick=BitOp_All_Purpose_01{1} if Bit_Debounce_Fire then goto done if Bit_Debounce_Joystick then goto done done Thanks. I just tried that with and without bank-switching and it compiled for me too. I tried it with the Titlescreen Kernel and it compiled. I added your score background color code and it compiled. The only thing I can think of is that there might be some naughty if-then that is a little too long. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 30, 2011 Author Share Posted August 30, 2011 (edited) Looks like it's causing the same problem as here: http://www.atariage.com/forums/topic/173010-what-mistake-would-make-new-defs-cause-errors/page__p__2145268#entry2145268 It's that old AND #65536 error popping up with Bit_Ship_Up. I've ripped out chunks of the program, trying to find what was causing the problem. I'd rip out a chunk, save, compile, rip out a chunk, save, compile . . . I ended up ripping out everything except the DIMs and DEFs, then it would finally compile. You'd think I would have found the cause of the problem by ripping out code piece by piece like that. I'll leave the current DEFs the way they are since they seem to be working, but I'll go back to the old way of using bits for anything new that I need to add. Edited August 30, 2011 by Random Terrain Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 31, 2011 Author Share Posted August 31, 2011 I'll leave the current DEFs the way they are since they seem to be working, but I'll go back to the old way of using bits for anything new that I need to add. I changed my mind. I converted all DEFs to DIMs: www.atariage.com/forums/blog/120/entry-8495-seaweed-assault-defs-to-dims/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.