Re: A86: Displaying a LOT of text!!! Question


[Prev][Next][Index][Thread]

Re: A86: Displaying a LOT of text!!! Question



Andres wrote:

>  Say I was making a program which has to display a lot of text
>  sequentially......this is done:
>  
>  ld hl,label1
>  call _vputs
>  
>  Now if label is defined at the end of program:
>  
>  label1:
>     .db "Text string",0
>  
>  The question is if hl is modifed by calling _vputs, and if not where is it
>  pointing? To the null byte of label1, or the byte after the null
>  character.....  Cause if there is another label after label1.....
>  
>  label1:
>     .db "Text string",0
>  label2:
>     .db "Text string 2",0
>  
>  Then could I do this:
>  
>  ld hl,label1
>  call _vputs
>  call _vputs ;If hl is not modified during the previous call to _vputs and
>  if its pointing to 
>  	    ; label2 then I could just call again?? - if it is modified then
could
>  I push
>  	    ; then pop of the stack.....
>  
>  Im trying I guess to come up with some sort of "engine" to display text
>  using very little code as possible..
>  
>  Im thinking like this:
>  
>  ; I have 5 lines of text to display... label1, label2, label3, etc.
>  ; Ill assum that hl is not modified during _vputs and its pointing to null
>  byte - meaning
>  ; it has to be incremented once top point to next label
>  
>  <-----Snip code---->
>    ld b,5		; # of labels
>    ld hl,label1
>  PutText:
>    call _vputs
>    inc hl 		; Is that in the instruction set?
>    djnz,PutText	;Is that the correct syntax?
>   
>  label1:
>    .db "Text string 1",0
>  
>  ; Rest of the labels below....

Well, I don't know about how _vputs affects hl, but I use the following code
to display  text in my programs:

<snip>
;***********************Display Text Routines**********************
;Description:   Draws text on the screen.
;Parameters:    hl -> Text struct (Row,Col,String,0)
;Output:	to screen only
;Destroys:	none
;Notes:		PutText -> Normal (big) Font
;		PutVWidth -> Variable Width (small/graph) Font

PutText:
        push bc                 ;Save bc
        ld c,(hl)               ;Load Row -> c
        inc hl                  ;(hl) -> Column
        ld b,(hl)               ;Load Column -> b
        inc hl                  ;Point (hl) -> Text
        ld (_curRow),bc         ;Load bc -> Cursor register
        call _puts              ;Put string
        pop bc                  ;Restore bc
        ret                     ;Done

PutVWidth:
        push bc                 ;Save bc
        ld b,(hl)               ;Load Row -> b
        inc hl                  ;(hl) -> Col
        ld c,(hl)               ;Load Col -> c
        inc hl                  ;Point (hl) -> Text
        ld (_penCol),bc         ;Load bc -> Pen register
        call _vputs             ;Put V-width string
        pop bc                  ;Restore bc
        ret                     ;Done

Text1:
            .db 0,12,"Top-Right",0         ;Row 0, Col 12 (for home screen
text)
<snip>

You could make a routine and a larger data struct that went something like
this:


Paragraph: .db 5         ;Number to display
.dw Label1,Label2,Label3,Label4,Label5         ;Stored low byte first
Label1: .db 0,0,"Welcome to my text displayer",0
Label2: .db 8,0,"Isn't this pretty?",0
Label3: .db 16,0,"All done with one call!",0
Label4: .db 24,0,"Download Chem86B",0
Label5: .db 32,0,"It might not crash your calc!",0


DisplayParagraph:        ;HL points to beginning
ld a,(hl)
ld b,a
DPDJNZLoop:
inc hl
ld e,(hl)
inc hl
ld d,(hl)
push hl
push de
pop hl
call PutVWidth
pop hl
djnz DPDJNZLoop
ret


That might work

~Stephen Hicks