Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 - Page 13 — Parallax Forums

Spin2

1101113151618

Comments

  • cgraceycgracey Posts: 14,206
    David Betz wrote: »
    cgracey wrote: »
    Oh, I forgot to mention that Jeff Martin is plugging the new compiler into the PropellerTool. That has scroll bars and context highlighting.
    What happened to PropellerIDE? I thought that was going to be the cross platform replacement for the PropellerTool. Will PropellerIDE be updated to work with Spin2?

    I don't know. It's easy for us to get PropellerTool running, though.
  • RaymanRayman Posts: 14,755
    edited 2020-02-10 21:06
    I just tried it on my 1080p FastSpin tile driver.
    I expected about 0% chance of it working...

    But, I'm giving it a go...
    So far:
    1. Had to fix "integer not allowed in floating-point expressions" issue
    2. Appears to want () after Pub method names, even if no parameters
    3. Got error on "add #read_1,#1". FastSpin allowed that first #, even though it is wrong...
    4. Methods with no arguments need () after name to call
    5. It doesn't like the @ in this return (gives error: expected end of line):
    PUB GetTiles() 'return address to tile pointer array
        return @Tiles
    
  • RaymanRayman Posts: 14,755
    I tried a work around on #5 above but got what looks like another problem...
    531 x 198 - 10K
  • cgraceycgracey Posts: 14,206
    edited 2020-02-10 21:23
    Rayman wrote: »
    I just tried it on my 1080p FastSpin tile driver.
    I expected about 0% chance of it working...

    But, I'm giving it a go...
    So far:
    1. Had to fix "integer not allowed in floating-point expressions" issue
    2. Appears to want () after Pub method names, even if no parameters
    3. Got error on "add #read_1,#1". FastSpin allowed that first #, even though it is wrong...
    4. Methods with no arguments need () after name to call
    5. It doesn't like the @ in this return (gives error: expected end of line):
    PUB GetTiles() 'return address to tile pointer array
        return @Tiles
    

    Rayman, I just looked into this. If you want a method to return some value(s), you need to put ': resultname{, result2name,...}' after the parameters declaration. So, there can only be return values if they are specified in the method declaration.
    PUB GetTiles() : ptr 'return address to tile pointer array
        return @Tiles
    

    Methods can return 0 to 15 values.
  • RaymanRayman Posts: 14,755
    edited 2020-02-10 21:31
    Ok, I got past that with this:
    PUB GetTiles():pTiles28934|i23432 'return address to tile pointer array
        i23432:=@Tiles
        return i23432
    

    But, it seems that local variables have to be globally unique?
    it won't work with just plain "i" or "pTiles"
  • cgraceycgracey Posts: 14,206
    Rayman wrote: »
    Ok, I got past that with this:
    PUB GetTiles():pTiles28934|i23432 'return address to tile pointer array
        i23432:=@Tiles
        return i23432
    

    But, it seems that local variables have to be globally unique?
    it won't work with just plain "i" or "pTiles"

    Local variables need to be distinguishable from globals.

    It sounds like you've already used 'i' and 'pTiles' globally. Is that the case?
  • RaymanRayman Posts: 14,755
    Ok, this seems to be a fundamental difference between FastSpin and Spin...

    The problem I have is that there is an "i" defined in an assembly DAT block.

    FastSpin doesn't seem to mind this, but Spin1 and Spin2 won't have it.
  • RaymanRayman Posts: 14,755
    I noticed a typo when looking through this code:
    PUB CreateP1Colors():i,j,k,l,m,r,g,b  'Create P2 version of the P1 colors from the P1 VGA demo
        'Need to create 24-bit colors from the 6-bit color P1 code
        'When stored at proper place in palette array, will be compatible with P1 text printing style
        repeat j from 0 to 15 step 2
    

    I guess this is defining several return variables that aren't actually being used to return anything...

    FastSpin let me get away with this. We'll see what Spin2 does soon...
  • whickerwhicker Posts: 749
    edited 2020-02-10 23:38
    @cgracey said:
    > Rayman wrote: »
    >
    > Ok, I got past that with this: PUB GetTiles():pTiles28934|i23432 'return address to tile pointer array i23432:=@Tiles return i23432
    >
    >
    > But, it seems that local variables have to be globally unique?
    > it won't work with just plain "i" or "pTiles"
    >
    >
    >
    >
    > Local variables need to be distinguishable from globals.
    >
    > It sounds like you've already used 'i' and 'pTiles' globally. Is that the case?

    Yeah that's not a practical restriction, Chip.

    Maybe prefix or suffix the variables internally, or have an additional scope byte that affects the hash?
  • cgraceycgracey Posts: 14,206
    So, you guys think it should be allowed to have local variables use the names of global variables? To me, that seems like a way to encourage bugs.
  • RaymanRayman Posts: 14,755
    Maybe not stuff declared in var
    But in dat should/might be ok?

    It’s fine when code is small...
    But with big code it is nice to have local variables be independent .

    Especially when combining code from separate files into one...
  • RaymanRayman Posts: 14,755
    It might be a tough call...
    Be more like Spin1 or C++
  • evanhevanh Posts: 16,032
    Maybe add a compile warning when locals are superimposing on globals.
  • I prefer to not allow local variables with the same names as global, as long as that doesn't apply across external objects you use (OBJ section).
    As in, if I use an OBEX object, will my global vars "collide" with it's locals causing it (the OBEX object) to fail to compile in the context of my program?
  • cgraceycgracey Posts: 14,206
    Since I have three different symbol tables now, one for locals, one for globals, and one for permanent symbols, It's easy to do things like this.

    You'd at least want to be sure that permanent symbols weren't being redefined, like REPEAT, or something.
  • cgraceycgracey Posts: 14,206
    > @"Roy Eltham" said:
    > I prefer to not allow local variables with the same names as global, as long as that doesn't apply across external objects you use (OBJ section).
    > As in, if I use an OBEX object, will my global vars "collide" with it's locals causing it (the OBEX object) to fail to compile in the context of my program?

    Object boundaries keep problems like that from happening.
  • RaymanRayman Posts: 14,755
    edited 2020-02-11 03:09
    It would be nice if an object file could get constants from its parent somehow ...

    Or maybe if constants in main file scoped to objects too
  • Chip,
    I thought that was the case. Just wasn't sure if it had changed with Spin2, due to some other change.
    If it's working the same as Spin1, then I say don't change it.

    If you do allow locals to have the same names as globals, then it should at the very least issue a warning, because it's likely to be a bug (or at the very least bad design).
  • RaymanRayman Posts: 14,755
    Let me elaborate...

    I could resolve this conflict by moving this dat section assembly code to a seperate file.
    But then, I face the challenge of passing all the constants it needs as variables... very tedious
  • RaymanRayman Posts: 14,755
    Being same as spin1 is fine
    Just seems like extra work for no reason

    I like to use i,j,k,x,y everywhere
  • Rayman,
    The reason for the "more work" is to make your code less likely to have bugs and easier to read by others.

    You can still use i,j,k,x,y everywhere except as globals.

    I think having the same names everywhere makes your code harder to read. Like if you have a variable "i" in global space AND in several local spaces, then how do you know what's what? A functions that has a local named "i" won't be able to access the global named "i" unless Chip adds yet another feature to allow you to prefix variable accesses with a "global scope" indicator. It's all just making it more of a mess.

    How did you deal with this in Spin1?
  • cgraceycgracey Posts: 14,206
    Rayman wrote: »
    Being same as spin1 is fine
    Just seems like extra work for no reason

    I like to use i,j,k,x,y everywhere

    Those single-letter variables are going to be used only within methods, I'd think. Why give global VARs such non-descriptive names when they won't meaningfully communicate ideas among methods?
  • cgraceycgracey Posts: 14,206
    edited 2020-02-11 23:36
    I found a bug in the interpreter, where the skip patterns for the multiply/divide assignment operations had a consistent '1' where they needed a '0'. Here is the latest:

    https://drive.google.com/file/d/1HWnhswX2fd3W9H1gYSFqNeWToBMO7N7T/view?usp=sharing

    I made a decimal printing routine that prints commas, too, in the VGA demo. There are two drivers now, one for 640x480 and another for 1280x1024, which provides 160x85 characters.

    Here is the VGA demo source code. You can see how SEND() can be used just like a PRINT in BASIC:
    CON _clkfreq = 250_000_000
    
    OBJ
      vga : "VGA_640x480_text_80x40_driver"		'_clkfreq >= 50MHz
    ' vga : "VGA_1280x1024_text_160x85_driver"	'_clkfreq >= 216MHz
    
    PUB go() | i, t
    
      vga.start(8)			'start vga
    
      send := @vga.print		'set send pointer
    
      send(4, $004040, 5, $00FFFF)	'cyan on dark cyan
    
      t := getct			'capture time
    
      i := @text			'print file
      repeat @textend-i
        send(byte[i++])
    
      i := getct			'capture time
    
      t := muldiv64(i - t, 1_000_000, clkfreq)	'get delta in microseconds
    
      send(12, "Elapsed time during printing was ", dec(t), " microseconds.")
    
    PRI dec(value) | flag, place, digit
    
      flag~
      place := 1_000_000_000
      repeat
        if flag ||= (digit := value / place // 10) or place == 1
          send("0" + digit)
          if lookdown(place : 1_000_000_000, 1_000_000, 1_000)
            send(",")
      while place /= 10
    
    DAT
    
    text	file	"VGA_640x480_text_80x40_driver.txt"
    textend
    
  • cgraceycgracey Posts: 14,206
    I made some HDTV text drivers and put them into the shared file in the post above.

    Here is 1080p HDTV in portrait mode - 135 columns by 160 rows of 8x12 font using 3-pin component signalling:

    1836 x 3264 - 437K
  • evanhevanh Posts: 16,032
    Looks good. I do like the aspect of the 8x12 fonts.
  • cgraceycgracey Posts: 14,206
    evanh wrote: »
    Looks good. I do like the aspect of the 8x12 fonts.

    The photo doesn't do it justice. The color is dingy and its blurry. On my desk here, it looks really nice.
  • cgraceycgracey Posts: 14,206
    edited 2020-02-11 12:25
    If we can get a file system together for the upper 15MB of flash, we'll have everything we need to make a computer.
  • RaymanRayman Posts: 14,755
    edited 2020-02-11 14:49
    Where is the clock being set in these 1080p examples? I'm not seeing it...


    Never mind, I see now that I'm supposed to use "vga_text_demo.spin2" as the top file.

    The 1080p examples don't work for me.
    I think it's because, despite being called from a file that starts with "VGA", it is not actually VGA.
    Looks like its actually component video...

    The first example, "VGA_640x480...", does work though.
  • RaymanRayman Posts: 14,755
    Var section is interesting...
    Looks like it assumes "Long" if nothing is specified?
  • RaymanRayman Posts: 14,755
    This syntax is not recognized by Fastspin:
        pinclear(av_base_pin_ addpins 4)
    

    Wouldn't that be better with commas?
Sign In or Register to comment.