Changing the colour Atributes at y,x (+3e BASIC)

edited July 2012 in Sinclair Basic
Hello there my fellow WoS'ers

I am currently writing away on my +3e and I am wonder is there a way I can just effect the Paper / Ink attributes at Y,X on the screen using BASIC?

What about the inverse of this - as in change just the graphic at Y,X but not the attributes (ink / paper) ?

I am writing a file browser / navigator and copier as a prototype in +3e BASIC to be precise.

Sorry for constantly opening thread / questions like these, I promise this will be my last one for a little bit ;)...... honest....


Thanks for reading.
Post edited by Zetr0 on

Comments

  • edited July 2012
    For the former: PRINT AT y,x; OVER 1; PAPER this; INK that;" "
    To do a whole line: PRINT AT y,0; OVER 1; PAPER this; INK that,,
    For the latter: PRINT AT y,x; PAPER 8; INK 8;"whatever"
  • edited July 2012
    Hiyas Battle Bunny

    Sorry I must of rephrased my question wrong.

    I wanted to just change the colour of an existing element at Y,X

    such that at 10,5 there is "Process List"; yellow ink, blue paper and bright

    I want to know (other than printing it out again) if its possible to effect the yellow ink / blue paper and bright ?

    perhaps using ATTR ?
  • edited July 2012
    I'd have thought it was easiest just to poke the new attribute at the relevant place.

    Do you want a function to change any arbitrary cell, or is this for highlighting some text in a directory listing etc, in which case you can make some shortcuts with the calculation.
    My rubbish website including the redrawn Amstrad schematics and the new home of the Sinclair FAQ wiki.
  • edited July 2012
    poke you say?

    well both infact,

    one to change a given cell's attribute properties.... (not that up on screen positions in POKES) and also would be handy to select text over bright/highlight and un-select too

    Mainly this bit saves me installing ASM on this laptop
  • edited July 2012
    Zetr0 wrote: »
    I wanted to just change the colour of an existing element at Y,X

    such that at 10,5 there is "Process List"; yellow ink, blue paper and bright

    Ye-e-e-es ... that's what that does; eg:
      10 PRINT AT 10,5; INK 6; PAPER 1; BRIGHT 1;"Process List"
      20 PAUSE 0
      30 PRINT AT 10,5; INK 5; PAPER 2; BRIGHT 0; OVER 1;TAB 17
    
    Line 30 changes the attributes for those character positions in the attributes file, and thus on the screen as well. ATTR will only tell you what the attributes are, not change them.

    The attributes could be poked directly, but then you've got to faff about calculating the attribute code and the start address and then use a POKE loop. Using PRINT ... OVER is easier.
  • edited July 2012
    I you want to use POKE, the way to calculate the address is:
    22528 + (row*32) + column
    where row is 0-23 and column is 0-31.
    If you PEEK that address you'll read off the attribute. If you POKE that address you can change the attribute.


    To calculate the attribute, you need to multiply the PAPER colour (0-7) by 8 and add to the INK colour. Then add another 64 for BRIGHT and 128 for FLASH. That should give you a number somewhere between 0 and 255.
    Joefish
    - IONIAN-GAMES.com -
  • edited July 2012
    This is where the lack of bitwise operators rears its ugly head of course. It makes turning bright on and off etc a pain :(

    Maybe using OVER 1 is a better way in that case.







    Course you know what you really want to do... Write it all in z80 :p

    ;)
    My rubbish website including the redrawn Amstrad schematics and the new home of the Sinclair FAQ wiki.
  • edited July 2012
    You guys are awesome!

    my thanks for your help and sound advice!
Sign In or Register to comment.