Jump to content
IGNORED

inty basic problem: stupid spaces


Recommended Posts

Hello. I have a little problem I hope you guys could solve. I put a copyright symbol in as a MOB. And to print it, I did

    print at 154 color $1202, "\319 2020"

Which is all well and good, but perhaps I don't want the space in between the copyright symbol and the year. You'd think there would be a way to do that, but I can't think of anything that would work.

  • Like 1
Link to comment
Share on other sites

Did you mean as a GRAM tile, not MOB?  (MOB = Sprite)

 

In any case, it feels like IntyBASIC should stop parsing the \ escape after 3 digits, but trying it just now, it appears it doesn't.  In the meantime, you could just do:

#backtab(154) = $1202 + 319*8
print at 155 color $1202, "2020"

 

Link to comment
Share on other sites

5 hours ago, atari2600land said:

Hello. I have a little problem I hope you guys could solve. I put a copyright symbol in as a MOB. And to print it, I did

 


    print at 154 color $1202, "\319 2020"

 

Which is all well and good, but perhaps I don't want the space in between the copyright symbol and the year. You'd think there would be a way to do that, but I can't think of anything that would work.

Perhaps a workaround might be:

print at 154 color $1202, "\319\

2020"

 

Link to comment
Share on other sites

Remember that PRINT can take multiple arguments so in this case the easy and obvious solution is:

 

PRINT AT 154 COLOR $1202,"\319","2020"

 

In a similar way, you can do this without breaking it into three parts:

 

PRINT AT 62,"PLAYER 1: ",<2>sc(0)," PTS"

PRINT AT 82,"PLAYER 2: ",<2>sc(1)," PTS"

Edited by carlsson
  • Like 1
Link to comment
Share on other sites

6 hours ago, carlsson said:

Remember that PRINT can take multiple arguments so in this case the easy and obvious solution is:

 

PRINT AT 154 COLOR $1202,"\319","2020"

 

 

Strangely, that results in more expensive code in IntyBASIC 1.4.1, as it saves and reloads the _screen pointer unnecessarily, and has to separately XOR in _color.

 

My way:

   ;[3] #backtab(154) = $1202 + 319*8
    SRCFILE "copr.bas",3
    MVII #7162,R0
    MVO R0,Q2+154
    ;[4] print at 155 color $1202, "2020"
    SRCFILE "copr.bas",4
    MVII #667,R0
    MVO R0,_screen
    MVII #4610,R0
    MVO R0,_color
    MVI _screen,R4
    MVII #144,R0
    XOR _color,R0
    MVO@ R0,R4
    XORI #16,R0
    MVO@ R0,R4
    XORI #16,R0
    MVO@ R0,R4
    XORI #16,R0
    MVO@ R0,R4
    MVO R4,_screen

 

Your way:

    SRCFILE "copr.bas",5
    ;[6]  PRINT AT 154 COLOR $1202,"\319","2020"
    SRCFILE "copr.bas",6
    MVII #666,R0
    MVO R0,_screen
    MVII #4610,R0
    MVO R0,_color
    MVI _screen,R4
    MVII #2552,R0
    XOR _color,R0
    MVO@ R0,R4
    MVO R4,_screen
    MVI _screen,R4
    MVII #144,R0
    XOR _color,R0
    MVO@ R0,R4
    XORI #16,R0
    MVO@ R0,R4
    XORI #16,R0
    MVO@ R0,R4
    XORI #16,R0
    MVO@ R0,R4
    MVO R4,_screen

 

Your way is definitely cleaner, though.  I suppose this is yet another opportunity for nanochess to optimize.

  • Like 1
Link to comment
Share on other sites

It is quickly turning into obfuscated code if one needs to know the character table in GROM, in particular as it is not ASCII compatible.

 

But yes, a POKE loop is even more efficient if you want:

 

  FOR i=0 TO 4:#backtab(154+i) = $1202 + text(i)*8:NEXT
  ...

text:
  DATA 319,18,16,18,16
Edited by carlsson
  • Like 1
Link to comment
Share on other sites

On 1/5/2020 at 4:02 AM, carlsson said:

It is quickly turning into obfuscated code if one needs to know the character table in GROM, in particular as it is not ASCII compatible.

 

But yes, a POKE loop is even more efficient if you want:

 


  FOR i=0 TO 4:#backtab(154+i) = $1202 + text(i)*8:NEXT
  ...

text:
  DATA 319,18,16,18,16

That's smaller in size, but I am pretty sure it's not faster speed-wise.  And, of course, there's packed character strings if you have a lot of text to deal with.

 

The GROM is mostly ASCII shifted down my $20, so it's somewhat ASCII compatible, much like PETSCII.

 

If you really want the smallest, fastest code, you probably end up with something like this:

#backtab(154) = $1202 + 319*8
#backtab(155) = $1202 + 18*8
#backtab(157) = $1202 + 18*8
#backtab(156) = $1202 + 16*8
#backtab(158) = $1202 + 16*8

Notice the ordering.  IntyBASIC takes advantage of the repeated value:

    MVII #7162,R0
    MVO R0,Q2+154
    MVII #4754,R0
    MVO R0,Q2+155
    MVO R0,Q2+157
    MVII #4738,R0
    MVO R0,Q2+156
    MVO R0,Q2+158

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, intvnut said:

If you really want the smallest, fastest code, you probably end up with something like this:


#backtab(154) = $1202 + 319*8
#backtab(155) = $1202 + 18*8
#backtab(157) = $1202 + 18*8
#backtab(156) = $1202 + 16*8
#backtab(158) = $1202 + 16*8

 

I suppose you could even make that almost readable with a couple macros like so:

DEF FN backtab_tile(color, tile) = color + (tile) * 8
DEF FN backtab_char(color, char) = color + (char - $20) * 8

#backtab(154) = backtab_tile($1202, 319)
#backtab(155) = backtab_char($1202, "2")
#backtab(157) = backtab_char($1202, "2")
#backtab(156) = backtab_char($1202, "0")
#backtab(158) = backtab_char($1202, "0")

 

  • Like 1
Link to comment
Share on other sites

I had actually asked @nanochess about this, particularly because "\\" wasn't implemented as an escape code to display a single backslash character.  In RobotFindsKitten, I ended up using "\60" which is the GROM character code for backslash.

 

But then I asked what would happen if I wanted to display "\1" because "\601" would give us garbage.  He said in the next release he would implement a limit of three digits, so "\0601" would give us what we wanted in this case.  I hope that helps.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...