Forum
64 char print - 32 lines version - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Wishlist (https://www.boriel.com/forum/forumdisplay.php?fid=14)
+---- Thread: 64 char print - 32 lines version (/showthread.php?tid=382)

Pages: 1 2


64 char print - 32 lines version - nitrofurano - 10-08-2011

Since zxbasic compiler has a library for 4x8 characters, how possible or easy to implement would be a 4x6 characters version?
[Image: charset4x6.png]


Re: 64 char print - 32 lines version - britlion - 10-11-2011

I did look into this, and I might well implement something someday. It's far harder than 4x8, however - 4 pixels is half a character square, and 8 is a full one, so it maps two new characters to a ZX Spectrum character square cleanly. 6 pixels high changes the start point of all the rows quite significantly; so it's a much harder thing to do.


Re: 64 char print - 32 lines version - nitrofurano - 10-12-2011

i don't know if the examples i posted at http://www.boriel.com/forum/help-support/interesting-performance-differences-with-sub-endsub-t681.html (related with coco2) can help somehow - my concern is mainly the code becoding relativelly more complex and slow - i have no idea about how the code could look like in assembly


Re: 64 char print - 32 lines version - boriel - 10-12-2011

As britlion says, 6pixel high don't fit into 8x8 ATTR square, and ZX Spectrum hardware is optimized for 8pixel height chars. 6pixel can be done, but their ATTR will clash, and it will be slower than the others.


Re: 64 char print - 32 lines version - nitrofurano - 10-14-2011

i were expecting attr clash - anyway the 6x8 version also has a bit of it anyway! Smile
i'm also expecting it being far slower than the others


Re: 64 char print - 32 lines version - nitrofurano - 10-23-2011

i don't know if this can be helpful for this library development (converted from the picture above):

Code:
defb 004h,004h,004h,000h,004h,000h
defb 0aah,0aeh,00ah,00eh,00ah,000h
defb 04ah,0e2h,0c4h,068h,0eah,040h
defb 0c4h,0c4h,060h,0c0h,0e0h,000h
defb 044h,082h,082h,082h,044h,000h
defb 040h,0e0h,0a4h,00eh,004h,000h
defb 000h,000h,000h,00eh,040h,080h
defb 002h,002h,004h,008h,048h,000h
defb 044h,0ach,0a4h,0a4h,04eh,000h
defb 0cch,022h,044h,082h,0ech,000h
defb 06eh,0a8h,0ach,0e2h,02ch,000h
defb 06eh,082h,0c2h,0a4h,044h,000h
defb 044h,0aah,046h,0a2h,044h,000h
defb 000h,000h,044h,000h,044h,008h
defb 000h,000h,04eh,080h,04eh,000h
defb 00ch,002h,044h,020h,044h,000h
defb 044h,0aah,0eah,08eh,06ah,000h
defb 0c4h,0aah,0c8h,0aah,0c4h,000h
defb 0ceh,0a8h,0ach,0a8h,0ceh,000h
defb 0e6h,088h,0cah,08ah,086h,000h
defb 0aeh,0a4h,0e4h,0a4h,0aeh,000h
defb 02ah,02ch,02ch,0aah,04ah,000h
defb 08ah,08eh,08eh,08eh,0eeh,000h
defb 0a4h,0eah,0eah,0eah,0a4h,000h
defb 0c4h,0aah,0aah,0ceh,086h,000h
defb 0c6h,0a8h,0a4h,0c2h,0ach,000h
defb 0eah,04ah,04ah,04ah,04eh,000h
defb 0aah,0aah,0aeh,0eeh,04ah,000h
defb 0aah,0aah,04eh,0a4h,0a4h,000h
defb 0eeh,028h,048h,088h,0eeh,000h
defb 08eh,082h,042h,022h,02eh,000h
defb 040h,0a0h,000h,000h,00eh,000h
defb 080h,04ch,002h,00eh,00eh,000h
defb 080h,0c6h,0a8h,0a8h,0c6h,000h
defb 020h,064h,0aeh,0a8h,066h,000h
defb 020h,046h,0eah,046h,042h,00ch
defb 084h,0c0h,0ach,0a4h,0aeh,000h
defb 048h,00ah,0cch,04ah,04ah,080h
defb 0c0h,04ch,04eh,04eh,0eeh,000h
defb 000h,0c4h,0aah,0aah,0a4h,000h
defb 000h,0c6h,0aah,0aah,0c6h,082h
defb 000h,0a6h,0cch,082h,08ch,000h
defb 040h,0eah,04ah,04ah,026h,000h
defb 000h,0aah,0aeh,0eeh,04eh,000h
defb 000h,0aah,04ah,0a6h,0a2h,00ch
defb 006h,0e4h,04ch,084h,0e6h,000h
defb 04ch,044h,046h,044h,04ch,000h
defb 060h,0c0h,000h,000h,000h,000h



Re: 64 char print - 32 lines version - nitrofurano - 10-23-2011

here is my very slow version of the code, not yet as library, and displaying some error messages from the compiler
surelly i did some very stupid mistakes here, and still without any assembly line beyond that 'defb' likes with the charmaps, and still missing the colour attribute part, but i think this can be a starting point for something - what do you all think about?

Code:
' ---------------------------------------------------------
' 64x32 characters print routine for zx basic
' started by nitrofurano, superficially based on some Britlion's code
' ---------------------------------------------------------

goto main1

sub printat64x32(y as ubyte, x as ubyte)
  poke @p64x32coords,x
  poke @p64x32coords+1,y
  end sub

function adr64x32(x as ubyte, y as ubyte, l as ubyte)
  i=((y*6+l)*32)+int(x/2)
  adrq=16384+((i band 31) bor ((i band 224)*8) bor ((i band 1792)/8) bor (i band 6144))
  return adrq
  end function

sub print64x32(characters$ as string)
  for i3=0 to len(characters$)-1
    e3=code(character$(i3))
    putchar64x32 (peek(@p64x32coords)+i3,peek(@p64x32coords+1),e3)
    next i3
  end sub

sub putchar64x32 (x1 as ubyte, y1 as ubyte, c1 as ubyte)
  maskanddsp=15*(1+15*(x1 band 1))
  maskandchm=15*(1+15*(c1 band 1))
  rtv=0
  if (c1 band 1)<(x1 band 1) then: rtv=1:end if '- /16
  if (c1 band 1)>(x1 band 1) then: rtv=2:end if '- *16
  for yq=0 to 5
    u1=peek(@p64x32_charset+yq+((c-32)*6))
    u2=u1 band maskandchm
    if rtv=1 then:u2=int(u2/16):end if
    if rtv=2 then:u2=int(u2*16):end if
    adq=adr64x32(x1,y1,l1)
    poke adq, peek(adq) band maskanddsp bor u2
    next
  end sub

p64x32_charset:
asm
  defb 004h,004h,004h,000h,004h,000h ; space !
  defb 0aah,0aeh,00ah,00eh,00ah,000h ; "" #
  defb 04ah,0e2h,0c4h,068h,0eah,040h ; $ %
  defb 0c4h,0c4h,060h,0c0h,0e0h,000h ; & '
  defb 044h,082h,082h,082h,044h,000h ; ( )
  defb 040h,0e0h,0a4h,00eh,004h,000h ; * +
  defb 000h,000h,000h,00eh,040h,080h ; , -
  defb 002h,002h,004h,008h,048h,000h ; . /
  defb 044h,0ach,0a4h,0a4h,04eh,000h ; 0 1
  defb 0cch,022h,044h,082h,0ech,000h ; 2 3
  defb 06eh,0a8h,0ach,0e2h,02ch,000h ; 4 5
  defb 06eh,082h,0c2h,0a4h,044h,000h ; 6 7
  defb 044h,0aah,046h,0a2h,044h,000h ; 8 9
  defb 000h,000h,044h,000h,044h,008h ; : ;
  defb 000h,000h,04eh,080h,04eh,000h ; < =
  defb 00ch,002h,044h,020h,044h,000h ; > ?
  defb 044h,0aah,0eah,08eh,06ah,000h ; @ A
  defb 0c4h,0aah,0c8h,0aah,0c4h,000h ; B C
  defb 0ceh,0a8h,0ach,0a8h,0ceh,000h ; D E
  defb 0e6h,088h,0cah,08ah,086h,000h ; F G
  defb 0aeh,0a4h,0e4h,0a4h,0aeh,000h ; H I
  defb 02ah,02ch,02ch,0aah,04ah,000h ; J K
  defb 08ah,08eh,08eh,08eh,0eeh,000h ; L M
  defb 0a4h,0eah,0eah,0eah,0a4h,000h ; N O
  defb 0c4h,0aah,0aah,0ceh,086h,000h ; P Q
  defb 0c6h,0a8h,0a4h,0c2h,0ach,000h ; R S
  defb 0eah,04ah,04ah,04ah,04eh,000h ; T U
  defb 0aah,0aah,0aeh,0eeh,04ah,000h ; V W
  defb 0aah,0aah,04eh,0a4h,0a4h,000h ; X Y
  defb 0eeh,028h,048h,088h,0eeh,000h ; Z [
  defb 08eh,082h,042h,022h,02eh,000h ; \ ]
  defb 040h,0a0h,000h,000h,00eh,000h ; ^ _
  defb 080h,04ch,002h,00eh,00eh,000h ; ? a
  defb 080h,0c6h,0a8h,0a8h,0c6h,000h ; b c
  defb 020h,064h,0aeh,0a8h,066h,000h ; d e
  defb 020h,046h,0eah,046h,042h,00ch ; f g
  defb 084h,0c0h,0ach,0a4h,0aeh,000h ; h i
  defb 048h,00ah,0cch,04ah,04ah,080h ; j k
  defb 0c0h,04ch,04eh,04eh,0eeh,000h ; l m
  defb 000h,0c4h,0aah,0aah,0a4h,000h ; n o
  defb 000h,0c6h,0aah,0aah,0c6h,082h ; p q
  defb 000h,0a6h,0cch,082h,08ch,000h ; r s
  defb 040h,0eah,04ah,04ah,026h,000h ; t u
  defb 000h,0aah,0aeh,0eeh,04eh,000h ; v w
  defb 000h,0aah,04ah,0a6h,0a2h,00ch ; x y
  defb 006h,0e4h,04ch,084h,0e6h,000h ; z {
  defb 04ch,044h,046h,044h,04ch,000h ; | }
  defb 060h,0c0h,000h,000h,000h,000h ; ~ (c)
  end asm

main1:
  border 5: paper 7:bright 1: ink 2: cls
  printat64x32(4,3)
  print64x32("Hello World!")
  pause 0


the error message i got is this:
Code:
guest@macbook_mint1 /mnt/sda4/trabalhos/programacao/8bit/zxspectrum/_sandbox/boriel_64x32 $ zxb.py -tBa print64x32.bas
Traceback (most recent call last):
  File "/opt/zxbasiccompiler/zxb.py", line 312, in <module>
    sys.exit(main(sys.argv)) # Exit
  File "/opt/zxbasiccompiler/zxb.py", line 241, in main
    zxbparser.parser.parse(input, lexer = zxblex.lexer, tracking = True, debug = (OPTIONS.Debug.value > 2))
  File "/mnt/sda4/opt/zxbasiccompiler/ply/yacc.py", line 263, in parse
    return self.parseopt(input,lexer,debug,tracking,tokenfunc)
  File "/mnt/sda4/opt/zxbasiccompiler/ply/yacc.py", line 710, in parseopt
    p.callable(pslice)
  File "/mnt/sda4/opt/zxbasiccompiler/zxbparser.py", line 3732, in p_code
    syntax_error_expected_string(p.lineno(1), NAME_TYPES[p[2]._type])
KeyError: None
guest@macbook_mint1 /mnt/sda4/trabalhos/programacao/8bit/zxspectrum/_sandbox/boriel_64x32 $



Re: 64 char print - 32 lines version - boriel - 10-24-2011

nitrofurano Wrote:here is my very slow version of the code, not yet as library, and displaying some error messages from the compiler
surelly i did some very stupid mistakes here, and still without any assembly line beyond that 'defb' likes with the charmaps, and still missing the colour attribute part, but i think this can be a starting point for something - what do you all think about?

the error message i got is this:
Code:
guest@macbook_mint1 /mnt/sda4/trabalhos/programacao/8bit/zxspectrum/_sandbox/boriel_64x32 $ zxb.py -tBa print64x32.bas
Traceback (most recent call last):
  File "/opt/zxbasiccompiler/zxb.py", line 312, in <module>
    sys.exit(main(sys.argv)) # Exit
  File "/opt/zxbasiccompiler/zxb.py", line 241, in main
    zxbparser.parser.parse(input, lexer = zxblex.lexer, tracking = True, debug = (OPTIONS.Debug.value > 2))
  File "/mnt/sda4/opt/zxbasiccompiler/ply/yacc.py", line 263, in parse
    return self.parseopt(input,lexer,debug,tracking,tokenfunc)
  File "/mnt/sda4/opt/zxbasiccompiler/ply/yacc.py", line 710, in parseopt
    p.callable(pslice)
  File "/mnt/sda4/opt/zxbasiccompiler/zxbparser.py", line 3732, in p_code
    syntax_error_expected_string(p.lineno(1), NAME_TYPES[p[2]._type])
KeyError: None
guest@macbook_mint1 /mnt/sda4/trabalhos/programacao/8bit/zxspectrum/_sandbox/boriel_64x32 $
This is a compiler bug (your code has a syntax error, but I will fix the compiler, so it will print such error msg.)


Re: 64 char print - 32 lines version - britlion - 10-24-2011

I'm playing with some code for this - I think the font is going to come in handy.

What /would/ be nice, since it's a bit slow, is to be able to have my screen address tables in the compiler as a #include option. I need to be able to #include it, and have it align and #include once basically.

Boriel, if I send you code for this are you okay with adding it to the distribution? I think a standard 4k screen address and similar rotate tables would be fairly common; and I can re-use them for quite a few screen routines. If they are in as standard library routines, such that they are guaranteed to only be inserted once, I don't have to worry about code duplication happening - using any of the sprite/graphics routines would include the tables once and once only.


Re: 64 char print - 32 lines version - nitrofurano - 10-27-2011

btw, i checked my code by testing it in part, and the compiler bug seems to be related with a variable name i used - i replaced 'character$' with 'name$', and that error message dissapeared.

btw, i have this code working now, with a 'Lorem ipsum' test - i had some bugs on some calculations as well - i think the issues now are still the slowness (i'm still an assembly noob for these things), and the attribute part (even clashy)

Code:
dim iq as uinteger
'-
function adr64x32(x0,y0,l0 as ubyte)
  iq=((y0*6+l0)*32)+int(x0/2)
  return (16384+((iq band 31) bor ((iq band 224)*8) bor ((iq band 1792)/8) bor (iq band 6144)))
  end function

dim maskanddsp,maskandchm,rtv,u1,u2,vq as ubyte
dim adq as uinteger
'-
sub putchar64x32(x1,y1,c1 as ubyte)
  maskanddsp=15*(1+15*((x1 band 1)))
  maskandchm=15*(1+15*(1-(c1 band 1)))
  c2=(int(c1/2))-16
  rtv=0
  if (c1 band 1)>(x1 band 1) then:
    rtv=1:end if '- /16
  if (c1 band 1)<(x1 band 1) then:
    rtv=2:end if '- *16
  for yq=0 to 5
    u1=peek(@p64x32charset+yq+(c2*6))
    u2=u1 band maskandchm
    if rtv=1 then:u2=int(u2*16):end if
    if rtv=2 then:u2=int(u2/16):end if
    adq=adr64x32(x1,y1,yq)
    vq=(peek(adq) band maskanddsp) bor u2
    poke adq,vq
    next
  end sub

dim i3,e3 as ubyte
'-
sub print64x32at(x2 as ubyte,y2 as ubyte,text$ as string)
  
  for i3=0 to len(text$)-1
    e3=code(text$(i3))
    putchar64x32(  (x2+i3) mod 64  ,y2 + int((x2+i3)/64)     ,e3)
    next i3
  end sub

'-------------------------

border 7:paper 7:ink 1:bright 1:cls
'border 1:paper 0:bright 1:ink 7:cls
'border 2:paper 1:bright 1:ink 7:cls

putchar64x32( 5,0,code("T"))
putchar64x32(10,1,code("U"))
putchar64x32(15,2,code("V"))
putchar64x32(20,3,code("W"))
putchar64x32(25,4,code("X"))
putchar64x32(30,5,code("Y"))
putchar64x32(35,6,code("Z"))
'print 60 band 15
'print chr$(87)

print64x32at(15,31,"Hello World! :) ")

print64x32at(5,15,"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")

pause 0
lp01:
goto lp01

'--------------------------

p64x32charset:
asm
  defb 004h,004h,004h,000h,004h,000h ; space !
  defb 0aah,0aeh,00ah,00eh,00ah,000h ; "" #
  defb 04ah,0e2h,0c4h,068h,0eah,040h ; $ %
  defb 0c4h,0c4h,060h,0c0h,0e0h,000h ; & '
  defb 044h,082h,082h,082h,044h,000h ; ( )
  defb 040h,0e0h,0a4h,00eh,004h,000h ; * +
  defb 000h,000h,000h,00eh,040h,080h ; , -
  defb 002h,002h,004h,008h,048h,000h ; . /
  defb 044h,0ach,0a4h,0a4h,04eh,000h ; 0 1
  defb 0cch,022h,044h,082h,0ech,000h ; 2 3
  defb 06eh,0a8h,0ach,0e2h,02ch,000h ; 4 5
  defb 06eh,082h,0c2h,0a4h,044h,000h ; 6 7
  defb 044h,0aah,046h,0a2h,044h,000h ; 8 9
  defb 000h,000h,044h,000h,044h,008h ; : ;
  defb 000h,000h,04eh,080h,04eh,000h ; < =
  defb 00ch,002h,044h,020h,044h,000h ; > ?
  defb 044h,0aah,0eah,08eh,06ah,000h ; @ A
  defb 0c4h,0aah,0c8h,0aah,0c4h,000h ; B C
  defb 0ceh,0a8h,0ach,0a8h,0ceh,000h ; D E
  defb 0e6h,088h,0cah,08ah,086h,000h ; F G
  defb 0aeh,0a4h,0e4h,0a4h,0aeh,000h ; H I
  defb 02ah,02ch,02ch,0aah,04ah,000h ; J K
  defb 08ah,08eh,08eh,08eh,0eeh,000h ; L M
  defb 0a4h,0eah,0eah,0eah,0a4h,000h ; N O
  defb 0c4h,0aah,0aah,0ceh,086h,000h ; P Q
  defb 0c6h,0a8h,0a4h,0c2h,0ach,000h ; R S
  defb 0eah,04ah,04ah,04ah,04eh,000h ; T U
  defb 0aah,0aah,0aeh,0eeh,04ah,000h ; V W
  defb 0aah,0aah,04eh,0a4h,0a4h,000h ; X Y
  defb 0eeh,028h,048h,088h,0eeh,000h ; Z [
  defb 08eh,082h,042h,022h,02eh,000h ; \ ]
  defb 040h,0a0h,000h,000h,00eh,000h ; ^ _
  defb 080h,04ch,002h,00eh,00eh,000h ; ? a
  defb 080h,0c6h,0a8h,0a8h,0c6h,000h ; b c
  defb 020h,064h,0aeh,0a8h,066h,000h ; d e
  defb 020h,046h,0eah,046h,042h,00ch ; f g
  defb 084h,0c0h,0ach,0a4h,0aeh,000h ; h i
  defb 048h,00ah,0cch,04ah,04ah,080h ; j k
  defb 0c0h,04ch,04eh,04eh,0eeh,000h ; l m
  defb 000h,0c4h,0aah,0aah,0a4h,000h ; n o
  defb 000h,0c6h,0aah,0aah,0c6h,082h ; p q
  defb 000h,0a6h,0cch,082h,08ch,000h ; r s
  defb 040h,0eah,04ah,04ah,026h,000h ; t u
  defb 000h,0aah,0aeh,0eeh,04eh,000h ; v w
  defb 000h,0aah,04ah,0a6h,0a2h,00ch ; x y
  defb 006h,0e4h,04ch,084h,0e6h,000h ; z {
  defb 04ch,044h,046h,044h,04ch,000h ; | }
  defb 060h,0c0h,000h,000h,000h,000h ; ~ (c)
  end asm



Re: 64 char print - 32 lines version - nitrofurano - 10-27-2011

for the attributes, i added this between 'sub putchar64x32(x1,y1,c1 as ubyte)' and 'end sub'

Code:
poke 22528+int(x1/2)+(int((y1*6)/8))*32,peek(23693)
    poke 22528+int(x1/2)+(int(((y1*6)+5)/8))*32,peek(23693)

it seems to work fine with 'ink', 'paper', 'bright' and 'flash'

what is missing now is getting values from 23694 (MASK P) for the 'colour 8' values, and 23697 (P FLAG) for the 'ink 9', 'paper 9', over and inverse - i'm also thinking about using those characters between 0x80 and 0x8F, and maybe some kind of udg as well (somehow) at 0x90 to 0xA4


Re: 64 char print - 32 lines version - nitrofurano - 10-27-2011

doing some more steps: while 'over' seems to work fine, 'inverse' is providing some weird behaviour i can't understand what is happening

here is the example.bas
Code:
#include <print64x32.bas>

border 7:paper 7:ink 1:bright 1:cls

' print at 3,2;inverse 1;ink 9;"teste"

for i=22528 to 22528+767:poke i,int(rnd*128):next i

ink 6:paper 8
for i= 64 to 4 step -4
circle 128,96,i
next i

print at 3,2;peek(23697) band 4
inverse 1
print at 4,3;peek(23697) band 4
inverse 0

'border 1:paper 0:bright 1:ink 7:cls
'border 2:paper 1:bright 1:ink 7:cls

ink 1
putchar64x32( 5,0,code("T"))
putchar64x32(10,1,code("U"))
putchar64x32(15,2,code("V"))
putchar64x32(20,3,code("W"))
putchar64x32(25,4,code("X"))
putchar64x32(30,5,code("Y"))
putchar64x32(35,6,code("Z"))
'print 60 band 15
'print chr$(87)

ink 2:paper 7
print64x32at(15,31,"Hello World! :) ")

ink 4:paper 7:bright 0:over 0:inverse 0
print64x32at(17,9,"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")

ink 3:paper 6:bright 1:over 0:inverse 1
print64x32at(4,15,"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")

paper 1:ink 5:bright 0:flash 1:inverse 0:over 1
a$=""
for i=32 to 127:a$=a$+chr$(i):next i
print64x32at(15,23,a$)

pause 0


and here the library, print64x32.bas
Code:
dim iq as uinteger
'-
function adr64x32(x0,y0,l0 as ubyte)
  iq=((y0*6+l0)*32)+int(x0/2)
  return (16384+((iq band 31) bor ((iq band 224)*8) bor ((iq band 1792)/8) bor (iq band 6144)))
  end function

dim maskanddsp,maskandchm,rtv,u1,u2,vq,adqv,adqvn as ubyte
dim adq as uinteger
'-
sub putchar64x32(x1,y1,c1 as ubyte)
  for iq=0 to 5 step 5:poke 22528+int(x1/2)+(int(((y1*6)+iq)/8))*32,peek(23693):next iq
  maskanddsp=15*(1+15*((x1 band 1)))
  maskandchm=15*(1+15*(1-(c1 band 1)))
  c2=(int(c1/2))-16
  rtv=0
  if (c1 band 1)>(x1 band 1) then:
    rtv=1:end if '- /16
  if (c1 band 1)<(x1 band 1) then:
    rtv=2:end if '- *16
  for yq=0 to 5
    u1=peek(@p64x32charset+yq+(c2*6))
    u2=u1 band maskandchm
    if rtv=1 then:u2=int(u2*16):end if
    if rtv=2 then:u2=int(u2/16):end if
    adq=adr64x32(x1,y1,yq)
    adqv=peek(adq)
    adqvn=255-adqv
    '- vq=(peek(adq) band maskanddsp) bor u2

    if (peek(23697) band 5)=0 then:  vq=(adqv band maskanddsp) bor u2 : end if
    if (peek(23697) band 4)<>0 then: vq=(adqvn band maskanddsp) bor u2 : end if :'- bug on inverse?
    if (peek(23697) band 1)<>0 then: vq=adqv bxor u2 : end if                   :'- over ok

    poke adq,vq
    next
  end sub

dim i3,e3 as ubyte
'-
sub print64x32at(x2 as ubyte,y2 as ubyte,text$ as string)
  
  for i3=0 to len(text$)-1
    e3=code(text$(i3))
    putchar64x32((x2+i3)band 63,y2+int((x2+i3)/64),e3)
    next i3
  end sub

goto lp01

'-------------------------

p64x32charset:
asm
  defb 004h,004h,004h,000h,004h,000h ; space !
  defb 0aah,0aeh,00ah,00eh,00ah,000h ; "" #
  defb 04ah,0e2h,0c4h,068h,0eah,040h ; $ %
  defb 0c4h,0c4h,060h,0c0h,0e0h,000h ; & '
  defb 044h,082h,082h,082h,044h,000h ; ( )
  defb 040h,0e0h,0a4h,00eh,004h,000h ; * +
  defb 000h,000h,000h,00eh,040h,080h ; , -
  defb 002h,002h,004h,008h,048h,000h ; . /
  defb 044h,0ach,0a4h,0a4h,04eh,000h ; 0 1
  defb 0cch,022h,044h,082h,0ech,000h ; 2 3
  defb 06eh,0a8h,0ach,0e2h,02ch,000h ; 4 5
  defb 06eh,082h,0c2h,0a4h,044h,000h ; 6 7
  defb 044h,0aah,046h,0a2h,044h,000h ; 8 9
  defb 000h,000h,044h,000h,044h,008h ; : ;
  defb 000h,000h,04eh,080h,04eh,000h ; < =
  defb 00ch,002h,044h,020h,044h,000h ; > ?
  defb 044h,0aah,0eah,08eh,06ah,000h ; @ A
  defb 0c4h,0aah,0c8h,0aah,0c4h,000h ; B C
  defb 0ceh,0a8h,0ach,0a8h,0ceh,000h ; D E
  defb 0e6h,088h,0cah,08ah,086h,000h ; F G
  defb 0aeh,0a4h,0e4h,0a4h,0aeh,000h ; H I
  defb 02ah,02ch,02ch,0aah,04ah,000h ; J K
  defb 08ah,08eh,08eh,08eh,0eeh,000h ; L M
  defb 0a4h,0eah,0eah,0eah,0a4h,000h ; N O
  defb 0c4h,0aah,0aah,0ceh,086h,000h ; P Q
  defb 0c6h,0a8h,0a4h,0c2h,0ach,000h ; R S
  defb 0eah,04ah,04ah,04ah,04eh,000h ; T U
  defb 0aah,0aah,0aeh,0eeh,04ah,000h ; V W
  defb 0aah,0aah,04eh,0a4h,0a4h,000h ; X Y
  defb 0eeh,028h,048h,088h,0eeh,000h ; Z [
  defb 08eh,082h,042h,022h,02eh,000h ; \ ]
  defb 040h,0a0h,000h,000h,00eh,000h ; ^ _
  defb 080h,04ch,002h,00eh,00eh,000h ; ? a
  defb 080h,0c6h,0a8h,0a8h,0c6h,000h ; b c
  defb 020h,064h,0aeh,0a8h,066h,000h ; d e
  defb 020h,046h,0eah,046h,042h,00ch ; f g
  defb 084h,0c0h,0ach,0a4h,0aeh,000h ; h i
  defb 048h,00ah,0cch,04ah,04ah,080h ; j k
  defb 0c0h,04ch,04eh,04eh,0eeh,000h ; l m
  defb 000h,0c4h,0aah,0aah,0a4h,000h ; n o
  defb 000h,0c6h,0aah,0aah,0c6h,082h ; p q
  defb 000h,0a6h,0cch,082h,08ch,000h ; r s
  defb 040h,0eah,04ah,04ah,026h,000h ; t u
  defb 000h,0aah,0aeh,0eeh,04eh,000h ; v w
  defb 000h,0aah,04ah,0a6h,0a2h,00ch ; x y
  defb 006h,0e4h,04ch,084h,0e6h,000h ; z {
  defb 04ch,044h,046h,044h,04ch,000h ; | }
  defb 060h,0c0h,000h,000h,000h,000h ; ~ (c)
  end asm

lp01:



Re: 64 char print - 32 lines version - nitrofurano - 10-28-2011

trying now the 'colour 8' and 'colour 9' - but i don't know what is going wrong here:

the library file, print64x32.bas
Code:
dim iq as uinteger
'-
function adr64x32(x0,y0,l0 as ubyte)
  iq=((y0*6+l0)*32)+int(x0/2)
  return (16384+((iq band 31) bor ((iq band 224)*8) bor ((iq band 1792)/8) bor (iq band 6144)))
  end function

dim maskanddsp,maskandchm,rtv,u1,u2,u1i,u2i,vq,adqv,adqvn,v1,v5,v6,adraq as ubyte
dim adq as uinteger
'-
sub putchar64x32(x1,y1,c1 as ubyte)
  for iq=0 to 5 step 5:

    '- previous version - only using attributes from 22528
    'poke 22528+int(x1/2)+(int(((y1*6)+iq)/8))*32,peek(23693)

    '- version for supporting colours 8 and 9
    adraq=22528+int(x1/2)+(int(((y1*6)+iq)/8))*32
    v1=peek(adraq)
    v5=(v1 band peek(23694)) bor (peek(23693) band (255-peek(23694))):v6=v5   :'- colour 8
    if (peek (23697) band 16)<>0 then:v6=(v5 band 248) bor ((1-(v5 band 32)/32)*7):end if :'- colour 9 - ink
    if (peek (23697) band 64)<>0 then:v6=(v5 band 199) bor ((1-(v5 band 4)/4)*56):end if  :'- colour 9 - paper
    poke adraq,v6

    next iq
  maskanddsp=15*(1+15*((x1 band 1)))
  maskandchm=15*(1+15*(1-(c1 band 1)))
  c2=(int(c1/2))-16
  rtv=0
  if (c1 band 1)>(x1 band 1) then:
    rtv=1:end if '- /16
  if (c1 band 1)<(x1 band 1) then:
    rtv=2:end if '- *16
  for yq=0 to 5
    u1=peek(@p64x32charset+yq+(c2*6))
    u1i=255-u1
    u2=u1 band maskandchm
    u2i=u1i band maskandchm
    if rtv=1 then:u2=int(u2*16):end if
    if rtv=2 then:u2=int(u2/16):end if
    adq=adr64x32(x1,y1,yq)
    adqv=peek(adq)
    adqvn=255-adqv
    '- vq=(peek(adq) band maskanddsp) bor u2

    if (peek(23697) band 5)=0 then:  vq=(adqv band maskanddsp) bor u2 : end if
    if (peek(23697) band 4)<>0 then: vq=(adqv band maskanddsp) bor u2i : end if :'- bug on inverse?
    if (peek(23697) band 1)<>0 then: vq=adqv bxor u2 : end if                   :'- over ok

    poke adq,vq
    next
  end sub

dim i3,e3 as ubyte
'-
sub print64x32at(x2 as ubyte,y2 as ubyte,text$ as string)
  
  for i3=0 to len(text$)-1
    e3=code(text$(i3))
    putchar64x32((x2+i3)band 63,y2+int((x2+i3)/64),e3)
    next i3
  end sub

goto lp01

'-------------------------

p64x32charset:
asm
  defb 004h,004h,004h,000h,004h,000h ; space !
  defb 0aah,0aeh,00ah,00eh,00ah,000h ; "" #
  defb 04ah,0e2h,0c4h,068h,0eah,040h ; $ %
  defb 0c4h,0c4h,060h,0c0h,0e0h,000h ; & '
  defb 044h,082h,082h,082h,044h,000h ; ( )
  defb 040h,0e0h,0a4h,00eh,004h,000h ; * +
  defb 000h,000h,000h,00eh,040h,080h ; , -
  defb 002h,002h,004h,008h,048h,000h ; . /
  defb 044h,0ach,0a4h,0a4h,04eh,000h ; 0 1
  defb 0cch,022h,044h,082h,0ech,000h ; 2 3
  defb 06eh,0a8h,0ach,0e2h,02ch,000h ; 4 5
  defb 06eh,082h,0c2h,0a4h,044h,000h ; 6 7
  defb 044h,0aah,046h,0a2h,044h,000h ; 8 9
  defb 000h,000h,044h,000h,044h,008h ; : ;
  defb 000h,000h,04eh,080h,04eh,000h ; < =
  defb 00ch,002h,044h,020h,044h,000h ; > ?
  defb 044h,0aah,0eah,08eh,06ah,000h ; @ A
  defb 0c4h,0aah,0c8h,0aah,0c4h,000h ; B C
  defb 0ceh,0a8h,0ach,0a8h,0ceh,000h ; D E
  defb 0e6h,088h,0cah,08ah,086h,000h ; F G
  defb 0aeh,0a4h,0e4h,0a4h,0aeh,000h ; H I
  defb 02ah,02ch,02ch,0aah,04ah,000h ; J K
  defb 08ah,08eh,08eh,08eh,0eeh,000h ; L M
  defb 0a4h,0eah,0eah,0eah,0a4h,000h ; N O
  defb 0c4h,0aah,0aah,0ceh,086h,000h ; P Q
  defb 0c6h,0a8h,0a4h,0c2h,0ach,000h ; R S
  defb 0eah,04ah,04ah,04ah,04eh,000h ; T U
  defb 0aah,0aah,0aeh,0eeh,04ah,000h ; V W
  defb 0aah,0aah,04eh,0a4h,0a4h,000h ; X Y
  defb 0eeh,028h,048h,088h,0eeh,000h ; Z [
  defb 08eh,082h,042h,022h,02eh,000h ; \ ]
  defb 040h,0a0h,000h,000h,00eh,000h ; ^ _
  defb 080h,04ch,002h,00eh,00eh,000h ; ? a
  defb 080h,0c6h,0a8h,0a8h,0c6h,000h ; b c
  defb 020h,064h,0aeh,0a8h,066h,000h ; d e
  defb 020h,046h,0eah,046h,042h,00ch ; f g
  defb 084h,0c0h,0ach,0a4h,0aeh,000h ; h i
  defb 048h,00ah,0cch,04ah,04ah,080h ; j k
  defb 0c0h,04ch,04eh,04eh,0eeh,000h ; l m
  defb 000h,0c4h,0aah,0aah,0a4h,000h ; n o
  defb 000h,0c6h,0aah,0aah,0c6h,082h ; p q
  defb 000h,0a6h,0cch,082h,08ch,000h ; r s
  defb 040h,0eah,04ah,04ah,026h,000h ; t u
  defb 000h,0aah,0aeh,0eeh,04eh,000h ; v w
  defb 000h,0aah,04ah,0a6h,0a2h,00ch ; x y
  defb 006h,0e4h,04ch,084h,0e6h,000h ; z {
  defb 04ch,044h,046h,044h,04ch,000h ; | }
  defb 060h,0c0h,000h,000h,000h,000h ; ~ (c)
  end asm

lp01:

and the example.bas file
Code:
#include <print64x32.bas>

border 0:paper 7:ink 1:bright 1:cls

for i=22528 to 22528+767:poke i,int(rnd*128):next i

ink 6:paper 8
for i= 94 to 15 step -4
circle 128,96,i
next i

print at 3,2;peek(23697) band 4
inverse 1
print at 4,3;peek(23697) band 4
inverse 0

ink 1
putchar64x32( 5,0,code("T"))
putchar64x32(10,1,code("U"))
putchar64x32(15,2,code("V"))
putchar64x32(20,3,code("W"))
putchar64x32(25,4,code("X"))
putchar64x32(30,5,code("Y"))
putchar64x32(35,6,code("Z"))

ink 2:paper 7
print64x32at(15,31,"Hello World! :) ")

'ink 3:paper 6:bright 1:over 0:inverse 1
ink 3:paper 9:bright 1:over 0:inverse 0
print64x32at(5,15,"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")

ink 4:paper 7:bright 0:over 0:inverse 0
print64x32at(17,9,"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")

paper 1:ink 5:bright 0:flash 1:inverse 0:over 1
a$=""
for i=32 to 127:a$=a$+chr$(i):next i
print64x32at(15,23,a$)

pause 0



Re: 64 char print - 32 lines version - britlion - 10-28-2011

Nicely done.

I am (without a lot of free time to do it in) looking at an assembly version of this. I did look at it about a year ago, and then never quite did it, so I have all sorts of snippets of code. I basically threw them all out and am starting again from scratch here, with the exception of probably stealing bits of font: there aren't many ways to write letters in 15 pixels.


That said: very nice work Nitro. I expect mine to be faster, (I can say great things about it: It's vapourware. It will also make dinner, entertain the kids and ensure world peace*) but it's good to see basic being able to produce.

Lion


* Not all features guaranteed to be in final version


Re: 64 char print - 32 lines version - nitrofurano - 10-28-2011

thanks! and as well, i'm curious to see your version working as well (and how will it look like coded in assembly)
about all the features (i think about that colour8/9, inverse, etc. which i were struggling a lot?), i think the important is having it minimally started, and later we would be implementing it as far as we try and get it working.
and thanks again for your feedback about! Smile