Could someone give me an example of a good screen shifting routine? I looked on ticalc but I couldn't find one. I particularly need one that can shift the screen to the left. Thanks Smile

EDIT:

So I was helpfully given this routine, but could some one explain how it works Razz


Code:
ld hl,$963F
ld c,$40
ld b,$0C
or a
rl (hl)
dec hl
djnz $-3
dec c
jr nz,$-9
ret
ld hl,$963F : loads the end of the screen buffer to the hl register.
ld c,$40 : loads 64 (The screen height) into c register.
ld b,$0C : loads 12 (The screen width in bytes) into b register
or a : clears the carry flag
rl (hl) : rotate the contents at hl left 1 bit. Cleared carry means 0 is written to bit 0.
dec hl : move to the previous address.
djnz $-3 : Do this loop for the whole screen width.
dec c \ jr nz,$-9 : Do this loop over the whole screen height.

Hopefully the next routines you find you can learn to analyze on your own Wink
The hex stuff was the stuff I wasn't sure about. Thanks for explaining Very Happy
I have another question. Let's say I have a value stored at the location "score". If I want to display that to the screen, and I store it in HL, what can I do to display it properly?
This is taken from the Alien Breed 5 source:

Code:
;------------------------------------------------
; setShowHL - show HL in small font at specified position (right aligned)
;   input:  HL = value to show
;           DE = penrow, pencol
;   output: none
;------------------------------------------------
setShowHL:
        ld      (pencol),de

;------------------------------------------------
; showHL - show HL in small font at cursor position (right aligned)
;   input:  HL = value to show
;   output: none
;------------------------------------------------
showHL:
        ld      de,showHLBuffer+5               ; DE => end of string buffer
        ld      b,5                             ; B = number of characters to calculate
        xor     a
        ld      (de),a                          ; set NULL terminator at end of string buffer and work backwards from there
showHLMake:
        dec     de                              ; DE => next character back
        bcall(_divHLby10)                       ; A = number to display
        add     a,'0'                           ; A = character to display
        ld      (de),a                          ; store it
        djnz    showHLMake
        ex      de,hl                           ; HL => start of string
; now check string and eliminate all leading zeros, and adjust pencol accordingly (string is right-aligned)
        ld      b,4                             ; B = number of characters to check (last character is always shown)
        ld      a,(pencol)                      ; A = pencol
showHLCheck:
        ld      c,a                             ; C = pencol
        ld      a,(hl)                          ; A = char
        cp      '0'                             ; is it a 0?
        ld      a,c                             ; A = pencol
        jr      nz,showHLReady                  ; if not, ready to show string
        add     a,4                             ; A = new pencol (skipping where this character would have been shown)
        inc     hl                              ; HL => next char in string
        djnz    showHLCheck
showHLReady:
        ld      (pencol),a                      ; set new pencol
        bcall(_vputs)
        ret
You just need to allocate a 6 byte space for "showHLBuffer", which creates a NULL terminated string based on the contents of HL, and displays it at (pencol) using _vputs. It trims off any leading zeros as well, so if HL = 143, then it displays "143", not "00143".

EDIT: If you *want* the leading zeros, you can erase the code from "ld b,4" onwards up until the "bcall(_vputs)" at the end Smile
Thanks a lot. There's a lot more to it than I expected Razz
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement