• Sprites and scrolling and BINs

    From Kirkman@GUARDIAN to All on Friday, January 09, 2015 15:00:36
    So I've been doing more experiments with sprites and scrolling and stuff.

    I've made some progress, but I've also run into some issues.

    First, echicken or MCMLXXIX or whoever, I have written a little function which can be added to frame.js, called scrollCircular(x,y). All it does is either
    pop or shift the frame data the create a constantly-looping scroll effect. I can post the code before too long if you're interested.

    But I keep running into trouble with BINs. Using techniques we talked about a few months ago, I make sprites and then mask their background to become transparent, so they can walk in front of things. This works.

    But I still don't understand the color values stored by frame.data[x][y].attr. In my case, I'm using green as the mask. What I have found is that if I load
    an ANSI image into the frame, the .attr for green characters is usually "2". But if I load the same image in BIN format, suddenly the green characters are "514." Why should these numbers be different? I don't get it.

    I also am not having much luck with my .BIN files. This is a multi-tiered problem, because I'm using a Mac. The newest versions of PabloDraw (which have Mac and Linux versions) have issues with loading/saving BINs. So I run the classic version of PabloDraw in WINE, and use it to convert ANS files to BIN.

    I find that no matter how hard I try, the BBS simply will not display the BIN properly. On the latest sprite I've been working on, the problem seems to come in the black characters. Not sure why. I posted some examples and some files
    on the Synchronet Facebook page if you're interested in looking:

    https://www.facebook.com/groups/448979361874853/636759266430194/

    I really want to get BINs to work because I want to use the sprite library.
    But for now I've had to make do simulating that library and just using frames with ANS data loaded.

    Here's an example of what I'm trying to do:

    https://vimeo.com/116376889

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    ■ Synchronet
  • From MCMLXXIX@MDJ to Kirkman on Friday, January 09, 2015 16:31:10
    Re: Sprites and scrolling and BINs
    By: Kirkman to All on Fri Jan 09 2015 15:00:36

    I find that no matter how hard I try, the BBS simply will not display the BI properly. On the latest sprite I've been working on, the problem seems to co in the black characters. Not sure why. I posted some examples and some files on the Synchronet Facebook page if you're interested in looking:

    https://www.facebook.com/groups/448979361874853/636759266430194/

    I really want to get BINs to work because I want to use the sprite library. But for now I've had to make do simulating that library and just using frame with ANS data loaded.

    When you create the Frame() in which you are loading the BIN file, either use no attributes or set it to BG_BLACK. The problem is that if you give a frame default attributes, anywhere there is no data (no character or attribute for a particular sector) it will fill it in with the defaults, I'm assuming from your screenshots that the attributes for the frame youre using are set to DARKGRAY, which would cause that anomaly.

    Let me know if this helps.

    ---
    ■ Synchronet ■ The BRoKEN BuBBLE (bbs.thebrokenbubble.com)
  • From echicken@ECBBS to Kirkman on Friday, January 09, 2015 17:55:06
    Re: Sprites and scrolling and BINs
    By: Kirkman to All on Fri Jan 09 2015 15:00:36

    But I still don't understand the color values stored by frame.data[x][y].attr. In my case, I'm using green as the mask. What I have found is that if I load an ANSI image into the frame, the .attr for green characters is usually "2". But if I load the same image in BIN format, suddenly the green characters are "514." Why should these numbers be different? I don't get it.

    I see that MCMLXXIX has already responded, but just thought I'd add a note:

    If you look in sbbsdefs.js where the attributes are defined, you'll see, among others:

    GREEN = 2;
    BG_BLACK = 0x200;

    If you OR the values of GREEN and BG_BLACK:

    var attr = 0x200|2;

    You will find that attr == 514.

    When you load a .ans into a frame, it likely contains sequences intended to change the terminal's current colour attributes. When Frame is parsing a .ans, it keeps track of what the current attributes are, so they carry over from one cell to the next.

    However in a .bin file, each character is paired with an attribute, and Frame should (arguably) be setting the attribute of each cell to the value read from the file. Evidently it doesn't do this, and the default attribute for the frame is being applied (as MCMLXXIX explained.) This may be by design, perhaps it's necessary for transparency or helpful in some other situation.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
  • From Kirkman@GUARDIAN to MCMLXXIX on Friday, January 09, 2015 22:02:01
    When you create the Frame() in which you are loading the BIN file, either use no attributes or set it to BG_BLACK. The problem is that if you give a frame default attributes, anywhere there is no data (no character or attribute for a particular sector) it will fill it in with the defaults,
    I'm assuming from your screenshots that the attributes for the frame youre using are set to DARKGRAY, which would cause that anomaly.

    Yes, this makes the difference. If I initialize the frame with BG_BLACK, the BIN appears correctly. Thanks!

    However, I can't set this value when I make a sprite.

    I tried replacing "0" with BG_BLACK in the frame init routines on lines 874
    and 1384 of sprite.js:

    this.frame = new Frame(x, y, this.ini.width, this.ini.height, BG_BLACK, parentFrame);

    This worked. The sprite rendered properly and I was able to mask it, no problems.

    --Josh


    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    ■ Synchronet
  • From MCMLXXIX@MDJ to echicken on Saturday, January 10, 2015 13:14:33
    Re: Sprites and scrolling and BINs
    By: echicken to Kirkman on Fri Jan 09 2015 17:55:06

    However in a .bin file, each character is paired with an attribute, and Fram should (arguably) be setting the attribute of each cell to the value read fr the file. Evidently it doesn't do this, and the default attribute for the frame is being applied (as MCMLXXIX explained.) This may be by design, perh it's necessary for transparency or helpful in some other situation.

    BIN files store a null bit in every spot where there is no character or attribute. If you use pablodraw to make a BIN, it doesn't fill every space with data, so these spots show up in the frame with no character or attributes.

    It might make more sense to load BIN files into a frame that has no default attributes at all (just omit the parameter for attr).. this is how transparency works in frame.js..



    ---
    ■ Synchronet ■ The BRoKEN BuBBLE (bbs.thebrokenbubble.com)
  • From MCMLXXIX@MDJ to Kirkman on Saturday, January 10, 2015 13:17:05
    Re: Re: Sprites and scrolling and BINs
    By: Kirkman to MCMLXXIX on Fri Jan 09 2015 22:02:01

    Yes, this makes the difference. If I initialize the frame with BG_BLACK, the BIN appears correctly. Thanks!

    However, I can't set this value when I make a sprite.

    I tried replacing "0" with BG_BLACK in the frame init routines on lines 874 and 1384 of sprite.js:

    this.frame = new Frame(x, y, this.ini.width, this.ini.height, BG_BLACK, parentFrame);

    if you pass "undefined" instead of "BG_BLACK" (without quotes) it will let you use transparency on the sprite. It's probably worth noting that if you really want that black outline around your sprite, you should explicitly draw it in the BIN file (instead of just leaving those spots empty) so that if you do use transparency that black outline wont be masked.

    ---
    ■ Synchronet ■ The BRoKEN BuBBLE (bbs.thebrokenbubble.com)
  • From Kirkman@GUARDIAN to MCMLXXIX on Saturday, January 10, 2015 14:07:11
    Re: Re: Sprites and scrolling and BINs
    By: MCMLXXIX to Kirkman on Sat Jan 10 2015 01:17 pm

    if you pass "undefined" instead of "BG_BLACK" (without quotes) it will let you use transparency on the sprite. It's probably worth noting that if you really want that black outline around your sprite, you should explicitly draw it in the BIN file (instead of just leaving those spots empty) so that if you do use transparency that black outline wont be masked.

    I actually did that, in fact. I was careful to make the black outline using
    the solid rectangle character (as opposed to a space) with black FG and black BG. But just because I drew it that way doesn't mean PabloDraw output it that way. I know there are other issues with the way PD outputs BIN files, and I've filed a bug report on those:

    http://picoe.ca/forums/topic/bin-handling/

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    ■ Synchronet