PBC equivelent to a VAR Overlay


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94

    Default PBC equivelent to a VAR Overlay

    I am converting a program from Bascom Basic to PBP. They have method of defining a VAR with a OVERLAY postscript.

    Here is their definition of Overlay
    Code:
    OVERLAY
    
    The OVERLAY option will not use any variable space. It will create a sort of phantom variable:
    
     
    
    Dim x as Long at $60 'long uses 60,61,62 and 63 hex of SRAM
    
     
    
    Dim b1 as Byte at $60 OVERLAY
    
    Dim b2 as Byte at $61 OVERLAY
    
     
    
    B1 and B2 are no real variables! They refer to a place in memory. In this case to &H60 and &H61. By assigning the phantom variable B1, you will write to memory location &H60 that is used by variable X.
    
    So to define it better, OVERLAY does create a normal usable variable, but it will be stored at the specified memory location which could be already be occupied by another OVERLAY variable, or by a normal variable.
    How would I go about translating this.

    Thanks

    Dave

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: PBC equivelent to a VAR Overlay

    Section 4.4 in the manual....
    Code:
    x VAR LONG     '32 bit variable - takes up actual RAM
    b1 VAR x.BYTE0        'Alias to byte 0.
    b2 VAR x.BYTE1
    b3 VAR x.BYTE2
    b4 VAR x.BYTE.3
    w1 VAR x.WORD0      'Alias to the low word of x
    w2 VAR x.WORD1      'Alias to the high word of x
    /Henrik.

  3. #3
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: PBC equivelent to a VAR Overlay

    Thanks Henrik

    so to translate from

    Code:
    Dim MyVar As Byte At Buffer + &H01 Overlay
    I would use

    Code:
    MyVar  VAR Buffer.Byte$01
    Thanks again

    Dave

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: PBC equivelent to a VAR Overlay

    Hi,
    No, in that case and as long as Buffer is a WORD (2bytes) or a LONG (4bytes) you can use:
    MyVar VAR Buffer.Byte1

    If Buffer is an array of BYTES ie.
    Buffer VAR BYTE[128]
    Then you need to index that array, like:
    MyVar1 VAR Buffer[0]
    MyVar2 VAR Buffer[1]
    MyVar3 VAR Buffer[75]

    And so on.

    /Henrik.

  5. #5
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: PBC equivelent to a VAR Overlay

    Thanks Henrik

    I got it.

    Dave

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts