Shop OBEX P1 Docs P2 Docs Learn Events
Bug? Simple_numbers.dec decstr memory corruption — Parallax Forums

Bug? Simple_numbers.dec decstr memory corruption

TransistorToasterTransistorToaster Posts: 149
edited 2007-03-22 15:58 in Propeller 1
Hello,
This memory corruption I encountered makes really no sense. I am basically working off from the graphics_demo.spin file where I just put in my own code to display what I need on the screen. For debugging purposes, I removed all cogs from my code such that I am only left with 1 tv cog, 1 graphics cog and the main cog. Here, the second text display function actually modifies the value of the previous one. I am probably missunderstanding something fundamental in object creation, the stack or some configuration with the TV ad GRAPHICS objects.
Any ideas please?



OBJ

  tv    : "tv"
  gr    : "graphics"
  simple_numbers: "Simple_Numbers"



PUB start | i, j, k, kk, dx, dy, pp, pq, rr, numx, numchr


 repeat
     k=200
     gr.text(80,50,simple_numbers.dec(k))
     k=200
     gr.text(160,50,simple_numbers.dec(f ))
     f:=f+1

Comments

  • Jeff MartinJeff Martin Posts: 755
    edited 2007-03-21 21:45
    Where is "f" defined in your code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Jeff Martin

    · Sr. Software Engineer
    · Parallax, Inc.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-22 00:06
    The f is defined in the VAR section as a long
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-22 08:45
    simple_numbers uses just a one string buffer when converting to strings. That means, values of that buffer is changed on the second call to the simple_numbers. It changes it before Graphics driver has drawn the text - text command just starts a command, but doesn't wait for it to finish, following is from the documentation of Graphics:

    PUB text(x, y, string_ptr)

    Draw text

    string_ptr - address of zero-terminated string (it may be necessary to call .finish
    immediately afterwards to prevent subsequent code from clobbering the
    string as it is being drawn

    So, you should call finish each time after text

    PUB finish

    Wait for any current graphics command to finish
    use this to insure that it is safe to manually manipulate the bitmap
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-22 15:58
    Jasper_M,
    Thanks for your advice.
Sign In or Register to comment.