Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
64 char print - 32 lines version
#7
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 $
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)