Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
64 char print - 32 lines version
#16
britlion Wrote: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.
I'm much more recovered now. I will debug the compiler (to fix the above crash error), and start working on it.
I've missed many threads and feel a bit "out" of some discussions. Sorry for that; it's not I'm not interested, but I was resting instead.
After debugging this error, I would also check those routines you say they worked on previous compiler versions and now they don't. This is essential before adding new features, etc...
Reply
#17
It was probably a case of cut n paste from here to the compiler puts spaces in front of # include.

This is two bugs:

1> Code in the forum copies/pastes with spaces in front of it for some reason.
2> (space)# include in the compiler generates an unhelpful error not at all related to the actual problem!
Reply
#18
nitrofurano Wrote: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.


Code:
...
sub print64x32at(x2 as ubyte,y2 as ubyte,characters$ as string)
  for i3=0 to len(characters$)-1
    e3=code(character$(i3)) ' <<== BUG wrong (undeclared) variable
    putchar64x32(  (x2+i3) mod 64  ,y2 + int((x2+i3)/64), e3)
    next i3
end sub
...
First of all, the above code has a bug: the parameter variable is characters$ whilst the inner variable is character$ (there is a missing -s at the end). They're different variables. The compiler crashed because it was not correctly managing this bug: when you use an undeclared alfanumeric VARIABLE$(Expression) it can mean be one of these 3 things:
  • VARIABLE$ is an array of Strings, and you want to get the i-th one (<expression>). This is discarded as undeclared arrays are not allowed (precisely to avoid this ambiguity)
  • VARIABLE$ is a function returning a string, and you want to get the result (<expression> is the parameter). This is also discarded, since ZX Basic requires you to use DECLARE to prototype functions in advance.
  • VARIABLE$ is a String, and you want the i-th character (string slicing). THIS is the meaning the compiler will get now since the other two are discarded.
Hope I've made things clear! :roll:
Reply
#19
Never enough time. Still. See attachment.

Doesn't do colour at the moment. (Not sure how it easily, can - the colour grid doesn't fit!)

Note that it's a print routine, so is coded to print(Y,X) format. 0<=Y<=31, 0<=X<=63

Also Uploaded as attachment, because I re-used the Screen Tables asm again. Which is enormous. This should only be ever loaded once - so If you use HRPRintFast, as well, for example, make sure screen and rotate tables only get included once.

This version also includes Block Graphics and UDG - there's a reference to @HiResPrintUdg embedded in the code so you can change these as you wish.

Edit: Slight bugfix in that it wasn't advancing print position correctly at end of string. Fixed
Edit2: Separated ScreenTables and RotateTables - Since I wasn't using rotate for this.


In Library: https://zxbasic.readthedocs.io/en/docs/l...t64x32.bas
Code:
SUB HiResPrintAt(Y as uByte,X as UByte)
Poke(@HiResPrintXCoord),X
Poke (@HiResPrintXCoord+1),Y
END SUB

SUB HiResPrintStringAt(y as ubyte,x as ubyte,text$ as string)
   HiResPrintAt(y,x)
   HiResPrint(text$)
END SUB


SUB HiResPrint (info as String)
ASM
; HL Points to string. Length, followed by bytes.

LD A,(HL)
LD C,A
INC HL
LD A,(HL)
LD B,A
INC HL
; BC Now contains our string length.
; HL Now points to first character.

HiresPrintStringLoop:

LD A,(HL)

PUSH BC
PUSH HL
CALL HiResPrintChar
POP HL
POP BC
Call HiResPrintUpdateCoordinates

DEC BC
LD A,B
OR C

JP Z,HiResPrintEnd

INC HL

JP HiresPrintStringLoop


JP HiResPrintEnd

HiResPrintChar:
; Arrives with Character in A

LD L,A                      ; HL=A*3
LD H,0                      ; |
ADD HL,HL                   ; |
ADD A,L                     ; |
LD  L,A                     ; |
JR NC, HiResPrintCharHop1   ; |
   INC H                    ; |
HiResPrintCharHop1:         ; v

LD DE,HiResPrintCharSet-96  ;Offset is because space=32, and it's a 3 byte table - so we go 96 bytes too far forward when mult by 3.
ADD HL,DE
; HL now points to Correct Character.            p

LD BC,(HiResPrint_X_Coord) ; Loads Y,X into BC
LD A,B    ; B=B*6
ADD A,A   ; |
LD B,A    ; |
ADD A,A   ; |
ADD A,B   ; |
LD B,A    ; v
; B now has 0-191 value for Y. C has X value in 0-63 format.

CALL HiResPrintScreenAddress
; DE now points at the screen address we need.


LD A,C
AND 1
LD A,%00001111
JP NZ,HiResPrintRightSide

HiResPrintLeftSide:
EXX
LD D,3

HiResPrintLeftSideLoop:
EXX

LD A,(HL)
AND %11110000
EXX
LD E,A
EXX
LD A,(DE)
AND %00001111
EXX
OR E
EXX
LD (DE),A

INC B
CALL HiResPrintScreenAddress
; HL Now has 2nd Line

LD A,(HL)
AND %00001111 ; Grab second four bits.
RLCA          ; Push to left side of byte.
RLCA
RLCA
RLCA

EXX
LD C,A
EXX
LD A,(DE)
AND %00001111
EXX
OR C
EXX
LD (DE),A

INC HL
INC B
CALL HiResPrintScreenAddress

EXX
DEC D
JR NZ, HiResPrintLeftSideLoop
EXX

RET

HiResPrintRightSide:
EXX
LD D,3

HiResPrintRightSideLoop:
EXX

LD A,(HL)
AND %11110000
RRCA        ;Push to right side.
RRCA
RRCA
RRCA

EXX
LD E,A
EXX
LD A,(DE)
AND %1111000
EXX
OR E
EXX
LD (DE),A

INC B
CALL HiResPrintScreenAddress
; HL Now has 2nd Line

LD A,(HL)
AND %00001111 ; Grab second four bits.

EXX
LD C,A
EXX
LD A,(DE)
AND %11110000
EXX
OR C
EXX
LD (DE),A

INC HL
INC B
CALL HiResPrintScreenAddress

EXX
DEC D
JR NZ, HiResPrintRightSideLoop
EXX

RET



; Screen address.
HiResPrintScreenAddress:

EX DE,HL
LD H,ScreenTables/256
LD L,B
LD A,(HL)
INC H
LD L,(HL)
LD H,A

LD A,C
SRL A ; Divide A(xcoord) by 2.
ADD A,L
LD L,A
EX DE,HL
RET

; Update Coordinates
HiResPrintUpdateCoordinates:
LD A,(HiResPrint_X_Coord)
INC A
CP 65
JR Z,HiResPrintOffLine
LD (HiResPrint_X_Coord),A
RET

HiResPrintOffLine:
XOR A

LD (HiResPrint_X_Coord),A
LD A,(HiResPrint_Y_Coord)
INC A
CP 33
JR Z, HiResPrintOffScreen
LD (HiResPrint_Y_Coord),A
RET

; Could scroll instead? Right now go back to top.
HiResPrintOffScreen:
XOR A
LD (HiResPrint_Y_Coord),A
RET


HiResPrintEnd:
END ASM

RETURN

HiResPrintXCoord:
ASM
; Variables
HiResPrint_X_Coord:
DEFB 1
HiResPrint_Y_Coord:
DEFB 10


#INCLUDE ONCE "ScreenTables.asm"

HiResPrintCharSet:
DEFB 0,0,0        ; SPACE
DEFB 34,32,32    ; !
DEFB 85,0,0        ; "
DEFB 87,87,80    ; #
DEFB 54,35,96    ; $
DEFB 65,36,16    ; %
DEFB 53,37,96    ; &
DEFB 18,0,0        ; '
DEFB 36,68,32    ; (
DEFB 33,17,32    ; )
DEFB 82,114,80    ; *
DEFB 2,114,0    ; +
DEFB 0,2,64        ; ,
DEFB 0,112,0    ; -
DEFB 0,0,32        ; .
DEFB 17,36,64    ; /
DEFB 37,85,32    ; 0
DEFB 38,34,112    ; 1
DEFB 37,18,112    ; 2
DEFB 97,97,96    ; 3
DEFB 19,87,16    ; 4
DEFB 116,97,96    ; 5
DEFB 52,101,32    ; 6
DEFB 113,18,64    ; 7
DEFB 37,37,32    ; 8
DEFB 37,49,96    ; 9
DEFB 2,2,0        ; :
DEFB 2,2,64        ; ;
DEFB 18,66,16    ; <
DEFB 7,7,0        ; =
DEFB 66,18,64    ; >
DEFB 97,32,32    ; ?
DEFB 97,53,112    ; @
DEFB 37,117,80    ; A
DEFB 101,101,96    ; B
DEFB 37,69,32    ; C
DEFB 101,85,96    ; D
DEFB 116,116,112; E
DEFB 116,116,64    ; F
DEFB 37,69,112    ; G
DEFB 85,117,80    ; H
DEFB 114,34,112    ; I
DEFB 17,21,32    ; J
DEFB 85,102,80    ; K
DEFB 68,68,112    ; L
DEFB 87,85,80    ; M
DEFB 101,85,80    ; N
DEFB 117,85,112    ; O
DEFB 101,100,64    ; P
DEFB 37,85,48    ; Q
DEFB 101,102,80    ; R
DEFB 52,33,96    ; S
DEFB 114,34,32    ; T
DEFB 85,85,96    ; U
DEFB 85,85,32    ; V
DEFB 85,87,80    ; W
DEFB 85,37,80    ; X
DEFB 85,34,32    ; Y
DEFB 113,36,112    ; Z
DEFB 100,68,96    ; [
DEFB 68,33,16    ; \
DEFB 49,17,48    ; ]
DEFB 39,34,32    ; ^
DEFB 0,0,15    ; _
DEFB 37,100,112    ; £
DEFB 6,53,112    ; a
DEFB 70,85,96    ; b
DEFB 3,68,48    ; c
DEFB 19,85,48    ; d
DEFB 3,86,48    ; e
DEFB 37,70,64    ; f
DEFB 3,83,96    ; g
DEFB 68,117,80    ; h
DEFB 64,68,96    ; i
DEFB 16,17,48    ; j
DEFB 69,102,80    ; k
DEFB 68,68,48    ; l
DEFB 5,117,80    ; m
DEFB 6,85,80    ; n
DEFB 7,85,112    ; o
DEFB 7,87,64    ; p
DEFB 7,87,16    ; q
DEFB 7,68,64    ; r
DEFB 6,66,96    ; s
DEFB 71,68,48    ; t
DEFB 5,85,96    ; u
DEFB 5,85,32    ; v
DEFB 5,87,80    ; w
DEFB 5,34,80    ; x
DEFB 5,113,96    ; y
DEFB 7,36,112    ; z
DEFB 50,66,48    ; {
DEFB 34,34,32    ; |
DEFB 98,18,96    ; }
DEFB 2,80,0        ; ~
DEFB 3,67,0        ; ©        
DEFB 0,0,0        ; <space>    <8>    (Block Graphics)
DEFB 51,48,0    ; TR    <1>    (Block Graphics)
DEFB 204,192,0    ; TL    <2>    (Block Graphics)
DEFB 255,240,0    ; Top    <3>    (Block Graphics)
DEFB 0,3,51        ; BR    <4>    (Block Graphics)
DEFB 51,51,51    ; Right    <5>    (Block Graphics)
DEFB 204,195,51    ; TL&BR    <6>    (Block Graphics)
DEFB 255,243,51    ; TL + Right    <7>    (Block Graphics)
DEFB 0,12,204    ; BL    <SH 7>    (Block Graphics)
DEFB 51,60,204    ; BL&TR    <SH 6>    (Block Graphics)
DEFB 204,204,204; Left    <SH 5>    (Block Graphics)
DEFB 255,252,204; Left + TR    <SH 4>    (Block Graphics)
DEFB 0,15,255    ; Bottom    <SH 3>    (Block Graphics)
DEFB 51,63,255    ; BL + Right    <SH 2>    (Block Graphics)
DEFB 204,207,255; Left + BR    <SH 1>    (Block Graphics)
DEFB 255,255,255; All 4    <SH 8>    (Block Graphics)
END ASM
HiResPrintUdg:
ASM
HiResPrintUdg:
DEFB 218,138,175    ; UDG A
DEFB 154,154,159    ; UDG B
DEFB 218,186,223    ; UDG C
DEFB 154,170,159    ; UDG D
DEFB 139,139,143    ; UDG E
DEFB 139,139,191    ; UDG F
DEFB 218,186,143    ; UDG G
DEFB 170,138,175    ; UDG H
DEFB 141,221,143    ; UDG I
DEFB 238,234,223    ; UDG J
DEFB 170,153,175    ; UDG K
DEFB 187,187,143    ; UDG L
DEFB 168,170,175    ; UDG M
DEFB 154,170,175    ; UDG N
DEFB 138,170,143    ; UDG O
DEFB 154,155,191    ; UDG P
DEFB 218,170,207    ; UDG Q
DEFB 154,153,175    ; UDG R
DEFB 203,222,159    ; UDG S
DEFB 141,221,223    ; UDG T
DEFB 170,170,159    ; UDG U
END ASM


END SUB

CLS
BORDER 2

HiResPrintStringAt(5,05,"T")
HiResPrintStringAt(6,10,"U")
HiResPrintStringAt(7,15,"V")
HiResPrintStringAt(8,20,"W")
HiResPrintStringAt(9,25,"X")
HiResPrintStringAt(10,30,"Y")
HiResPrintStringAt(11,35,"Z")

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

HiResPrintStringAt(15,5,"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.")

HiResPrintAt(0,0)

For n=32 to 164
HiResPrint(CHR$(n)+" ")
next n

PAUSE 1
PAUSE 0


Attached Files
.7z   64X32Print.7z (Size: 8.92 KB / Downloads: 874)
Reply
#20
i'm testing it now - awesome! - the speed is really impressive! very thanks! Smile
Reply
#21
Britlion, don't worry about the colour (at least for now) - i think my version is "fast" enough for that, and i think wouldn't be a problem when 'applied' over that somehow (the method i used is the attribute value were applied over its area on each 'y=0' and 'y=5' pixel line of each character, i understand perfectly how hard is calculating it on assembly ) - only missed the trickest part you did very successfully, the bitmap part! - thanks again! Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)