Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ULAplus support
#3
Another update

The first one is related to a more simple use of 'ink' and 'paper' - since it's a bit hard to locate a colour between 0 and 63 using 'ink:paper:bright:flash:inverse', i added a sub that gives priority to 'ink' (between 0 and 63), and uses the less significative 3 bits from paper, due on ULAplus limitation (which is limited to use the same 16 colour group from ink, and not the same 8 colour group) - i think the code example explains a bit how it works.

The other function i added is related to use more easily hexcolours on ULAplus - for example, besides the hexcolour format used on webpages, for red colour, is '#FF0000', it would be 12bit instead of 24bit, like '#F00', which on the code will be used as '0F00h'

on the example, i used the colour 15 for the border because it were the 'border 7' (and 'paper 7:flash 0: bright 0'), colour 0 for the default ink (ink 0:flash 0:bright 0), and all other between colour 48 and colour 63, for illustrating how is it used on the last of all 4 16c cluts (equivalent of 'flash 1: bright 1')

library/ulaplus.bas
Code:
'- ULAplus library for Boriel's zxbasic-compiler
'- 20111205164150 - (ↄ) Paulo Silva - http://nitrofurano.altervista.org
'- This file is released under the GPL v3 License

dim tmpv as uinteger
dim fdbkv as ubyte

function ulapluscheck():
  tmpv=in(65339):pause 1:fdbkv=0
  out 48955,0:out 65339,0:pause 1
  if in(65339)<>tmpv then:fdbkv=1:out 48955,0:out 65339,tmpv:pause 1:end if
  return fdbkv
  end function

sub ulapluspalette(clv as ubyte, vlv as ubyte):
  out 48955,(clv band 63):out 65339,vlv:pause 1
  end sub

function ulaplusgetpalette(clv as ubyte)
  out 48955,(clv band 63)
  return in(65339)
  pause 1
  end function

sub ulaplusswitch(flgv as ubyte):
  out 48955,64:out 65339,(flgv band 1):pause 1
  end sub

sub ulaplusattr(ikv as ubyte,pav as ubyte):
  '- usage: ink priority (from 0 to 63), and only using 3 bits lsb from paper
  inverse 0:ink(ikv band 7):paper(pav band 7)
  bright((ikv band 16)/16):flash((ikv band 32)/32)
  if (ikv band 8)<>0 then:
    inverse 1:ink(pav band 7):paper(ikv band 7)
    end if
  end sub

function ulaplushexcolour(hxcv as uinteger):
  tmpv=(hxcv band 12)/4
  tmpv=tmpv bor(hxcv band 224)
  hxcv=int(hxcv/256)
  tmpv=tmpv bor((hxcv band 14)*2)
  return tmpv
  end function

example01.bas
Code:
#include "library/ulaplus.bas"
ulaplusswitch(1):cls
bold 1

ulaplusattr(0,15)
cls
ulapluspalette(0,ulaplushexcolour(0398h))
ulapluspalette(15,ulaplushexcolour(0275h))
ulapluspalette(57,ulaplushexcolour(0874h))
ulapluspalette(49,ulaplushexcolour(0543h))
ulapluspalette(58,ulaplushexcolour(0783h))

print at 0,0;"";
print "test - using palette from http://www.colourlovers.com/palette/1779157/Reflect_Hope_F?widths=0":print
print "hexcolours (12bit):"
print "#275,#874,#398,#543,#783":print

ulaplusattr(49,57):print "hello world!"
ulaplusattr(57,49):print "hello world!":print

ulaplusattr(49,58):print "hello world!"
ulaplusattr(58,49):print "hello world!":print

ulaplusattr(15,15):print "\::";
ulaplusattr(57,57):print "\::";
ulaplusattr(0,0):print "\::";
ulaplusattr(49,49):print "\::";
ulaplusattr(58,58):print "\::";

pause 0

screenshot:
[Image: 201112051653251280x800s.th.png]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)