User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 23

Thread: Are there any global registers?

  1. #11
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,729
    Level
    17
    vBActivity - Bars
    Lv. Percent
    2.5%

    Re: Are there any global registers?

    So there really are gd0-gd255?
    Avatar: Just who the SPAAAACE do you think I am?

  2. #12
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,451
    Level
    24
    vBActivity - Bars
    Lv. Percent
    73.19%

    Re: Are there any global registers?

    Yeah. You can access them using precisely those names in ZASM. In ZScript, you can't access them directly; you just create a global variable, and the compiler will find a place for it. Since you don't know what it'll pick, it can be dangerous to mix ZASM and ZScript in a single quest.

  3. #13
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,729
    Level
    17
    vBActivity - Bars
    Lv. Percent
    2.5%

    Re: Are there any global registers?

    So how do you declare a global variable? Will it save when you save your game? Can you access local variables directly using ZScript?
    Avatar: Just who the SPAAAACE do you think I am?

  4. #14
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,451
    Level
    24
    vBActivity - Bars
    Lv. Percent
    73.19%

    Re: Are there any global registers?

    So how do you declare a global variable?
    Anything declared within the script body, outside of any method, is automatically global. It can be referred to from another script using scriptName.variableName.
    This may change, though.

    Will it save when you save your game?
    ... I think so, yeah. I'll have to check and make sure, but I think they're saved.

    Can you access local variables directly using ZScript?
    I'm not sure I know what you mean... That's pretty much the only way you would access them.

  5. #15
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,047
    Level
    31
    vBActivity - Bars
    Lv. Percent
    10.69%

    Re: Are there any global registers?

    I'm very interested in this bug. When Saffith's sample script is compiled, temp will be stored on foo's stack. Since each script SHOULD have a separate stack, that two script's local variables are interfering with each other indicates something has gone horribly wrong at runtime.
    Could somebody take two scripts which are known to interfere with each other, and pare them down to a minimal set of scripts that still exhibit the bug? As soon as we get two SMALL scripts that illustrate the bug, we need to look at the ASM dumps and determine if the bug is both a compile-time and runtime bug or just runtime.

  6. #16
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,451
    Level
    24
    vBActivity - Bars
    Lv. Percent
    73.19%

    Re: Are there any global registers?

    This is about as small as I can manage.
    I'm fairly certain it has something to do with this. If I avoid it, there's never a problem.

    Code:
    ffc script foo
    {
    	void run()
    	{
    		int var=this->X;
    		Trace(var);
    	}
    }
    
    ffc script bar
    {
    	void run()
    	{
    		int var=this->X;
    		Trace(var);
    	}
    }
    I compile those, attach foo to FFC #1 and bar to FFC #2, and it prints the position of #1 twice.

    Code:
    foo
     SETV d2,0
     SETR d3,REFFFC
     PUSHR d3
     PUSHR d2
     SETR d4,SP
     PUSHR d4
     SETV d2,14
     PUSHR d2
     SETR d6,d4
     ADDV d6,0
     LOADI d2,d6
     PUSHR d2
     GOTO 34
     POP d4
     SETR d6,d4
     ADDV d6,1
     STOREI d2,d6
     PUSHR d4
     SETV d2,26
     PUSHR d2
     SETR d6,d4
     ADDV d6,1
     LOADI d2,d6
     PUSHR d2
     GOTO 30
     POP d4
     SETV d3,0
     POP d3
     QUIT
     POP d3
     TRACER d3
     POP d3
     GOTOR d3
     POP d3
     SETR REFFFC,d3
     SETR d2,X
     POP d3
     GOTOR d3
    
    bar
     SETV d2,0
     SETR d3,REFFFC
     PUSHR d3
     PUSHR d2
     SETR d4,SP
     PUSHR d4
     SETV d2,14
     PUSHR d2
     SETR d6,d4
     ADDV d6,0
     LOADI d2,d6
     PUSHR d2
     GOTO 34
     POP d4
     SETR d6,d4
     ADDV d6,1
     STOREI d2,d6
     PUSHR d4
     SETV d2,26
     PUSHR d2
     SETR d6,d4
     ADDV d6,1
     LOADI d2,d6
     PUSHR d2
     GOTO 30
     POP d4
     SETV d3,0
     POP d3
     QUIT
     POP d3
     TRACER d3
     POP d3
     GOTOR d3
     POP d3
     SETR REFFFC,d3
     SETR d2,X
     POP d3
     GOTOR d3
    Also, if I only use one of those and attach it to both FFCs, I get the same output.

    Code:
    ffc script foo
    {
    	void run()
    	{
    		int var=this->X;
    		Trace(var);
    	}
    }
    Same ol' ASM.
    Code:
    foo
     SETV d2,0
     SETR d3,REFFFC
     PUSHR d3
     PUSHR d2
     SETR d4,SP
     PUSHR d4
     SETV d2,14
     PUSHR d2
     SETR d6,d4
     ADDV d6,0
     LOADI d2,d6
     PUSHR d2
     GOTO 34
     POP d4
     SETR d6,d4
     ADDV d6,1
     STOREI d2,d6
     PUSHR d4
     SETV d2,26
     PUSHR d2
     SETR d6,d4
     ADDV d6,1
     LOADI d2,d6
     PUSHR d2
     GOTO 30
     POP d4
     SETV d3,0
     POP d3
     QUIT
     POP d3
     TRACER d3
     POP d3
     GOTOR d3
     POP d3
     SETR REFFFC,d3
     SETR d2,X
     POP d3
     GOTOR d3

  7. #17
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,630
    Level
    25
    vBActivity - Bars
    Lv. Percent
    2.86%

    Re: Are there any global registers?

    Saffith, do you want to forward that quest file I emailed you on to DarkDragon? If he wanders around that quest for awhile (normal cheats enabled) he'll find some examples of the bizzare FFC behavior first hand.

  8. #18
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,047
    Level
    31
    vBActivity - Bars
    Lv. Percent
    10.69%

    Re: Are there any global registers?

    Code:
    1 SETV d2,0 ; placeholder
    2 SETR d3,REFFFC ; value of the this pointer
    3 PUSHR d3
    4 PUSHR d2 
    5 SETR d4,SP
    6 PUSHR d4 ; stack is now: 0, this, 254
    7 SETV d2,14 ; return value
    8 PUSHR d2 
    9 SETR d6,d4
    10 ADDV d6,0
    11 LOADI d2,d6 ; d2 is now this
    12 PUSHR d2 ; stack is now 0, this, 254, 14, this
    13 GOTO 34
    14 POP d4 ; SP is popped off of the stack. Stack is now 0, this. d2 holds X.
    15 SETR d6,d4
    16 ADDV d6,1 
    17 STOREI d2,d6 ; Stack is now X, this.
    18 PUSHR d4 ; Stack is now X, this, 254
    19 SETV d2,26 ; return value
    20 PUSHR d2 ; stack is now X, this, 254, 26
    21 SETR d6,d4
    22 ADDV d6,1
    23 LOADI d2,d6 ; d2 now holds X
    24 PUSHR d2 ; stack is now X, this, 254, 26, X
    25 GOTO 30
    26 POP d4 ; pops SP off of the stack. Stack is now X, this
    27 SETV d3,0 ; NOP
    28 POP d3
    29 QUIT
    
    30 POP d3 ; pops X off of the stack
    31 TRACER d3
    32 POP d3 ; pops return value 26 off of the stack
    33 GOTOR d3
    
    34 POP d3 ; this is popped off of the stack
    35 SETR REFFFC,d3
    36 SETR d2,X ; d2 is now X
    37 POP d3 ; 14 is popped off of the stack
    38 GOTOR d3
    I've added line numbers, some commentary, and split the subroutines off of your ASM dump; if there's a bug in the ASM I don't see it.

    What happens if you run two FFCs on the same screen with the following ZASM script:
    Code:
    LOADR d3, REFFFC
    TRACER d3
    QUIT

  9. #19
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,451
    Level
    24
    vBActivity - Bars
    Lv. Percent
    73.19%

    Re: Are there any global registers?

    You meant SETR, not LOADR, right?

    I attached it to eight different FFCs. For the first two, the output isn't entirely predictable. One of them prints #1's X position, and the other one prints 0. It seems as if the order of those two somehow depends on their positions.
    For FFCs #3-8, however, it simply prints the numbers 2-7 in order.

  10. #20
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,729
    Level
    17
    vBActivity - Bars
    Lv. Percent
    2.5%

    Re: Are there any global registers?

    Yes, but how do you declare a global variable that can be acessed anywhere in the game?
    Avatar: Just who the SPAAAACE do you think I am?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social