A86: TEXT VIEWER FINALLY


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

A86: TEXT VIEWER FINALLY



HERE IS MY TEXT VIEWER
SORRY FOR LACK OF COMMENTS,A future version will come
Get Your Private, Free Email at http://www.hotmail.com
; ------------------------ TEXT VIEWER IN SMALL FONT ---------------------------------------
; 
; This text viewer was done by me Olivier 'OBones' SANNIER in order to display a string in
; small font onto the ti86 screen. I needed it for My exams last year
; sorry for the bad comments, a future version will come.
; You can use part of this code in your own prog but never forget to mention my name
; I'm not repsonsible for any damage caused to your calc (musn't happen but...)
;
; please send any comments at OBones@hotmail.com 
;
; This program was developped with Assembly Studio 2.0 and 3.0a
; (c) 1997-1998 Olivier 'OBones' SANNIER

#include "ti86asm.inc"
#include "ti86und.inc"
#include "ti86ops.inc"
; these 3 includes are from Assembly Studio ones (a must have)

.org _asm_exec_ram

	Call    RecupChaine						; gets the string to display from the ram
	Call    FormateChaine					; formats string to fit my requirements
	Call    AfficheMenu                     ; Displays menu (sorry, didn't know menu calls)
	call    _runindicoff					; no run indicator
	ld              a, 9                            ; the last displayable line is number 9
	ld              hl, Avant
	ld              (hl), 0
Debut:
	ld              hl, numligne
	ld              b, (hl)                         ; b = max line number to display
	cp              b                                       ; compares a to b
	jp              M, Suite                        ; if a < b then jump
	ld              a, b                            ; else a = b
Suite:
	push    af								; saves a register
	ld              hl, avant			
	ld              b, (hl)					; gets the string number that was displayed before
	cp              b
	Call    nz, Affiche                     ; Only displays if line has been changed
											; this prevents from flickering
	ld              hl, avant
	ld              (hl), a
	call    _getkey                         ; Wait for a key in order to do the menu
	cp              kF1
	jr              nz, Suivante1
	pop             af
	add             a, 9
	jr              Debut
Suivante1:
	cp              kF2
	jr              nz, Suivante2
	pop             af
	cp              9
	jp              P, Bon
	ld              hl, numligne
	ld              a, (hl)
	jr              debut
Bon:
	sub             9
	cp              9
	jp              P, Debut
	ld              a, 9
	jr              Debut
Suivante2:
	cp              kF4
	jp              nz, Suivante3
	call    detruitchaine
	pop             af
	call    _clrScrn
	call    _homeup
	ret
Suivante3:
	cp              kF5
	jp              nz, Suivante4
	call    _clrlcd
	call    detruitchaine
	jp              _jforcecmdnochar
Suivante4:
	cp              kExit
	jp              nz, Suivante5
	call    _clrScrn
	call    _homeup
	call    detruitchaine
	pop             af
	ret
Suivante5:
	cp              kQuit
	jp              nz, Suivante6
	call    _clrLCD
	call    detruitchaine
	jp              _jforcecmdnochar
Suivante6:
	cp              kUp
	jr              nz, Suivante7
	pop             af
	cp              10
	jp              P, Bon2
	ld              a, 9
	jp              debut
Bon2:
	dec             a
	jp              debut
Suivante7:
	cp              kDown
	jp              nz, Autre
	pop             af
	inc             a
	jp              Debut
Autre:
	pop             af
	jp              Suite
	Ret     

; ---------------------------------------------------
; destroys the string called chaine in the TI86 RAM
DetruitChaine:
	call    _runindicon
	ld              hl, (FinChaine) 
	ex              de, hl
	push    de
		call    ChargePageMem					; gets the good ram pages
	ld              hl, OctetsPerdus
	ld              bc, 2
	pop             de                                              
	ldir                                                    ; rewrite the two lost bytes
		call    RetourPageNormales				; set the normal pages
	
	ld              hl, var
	rst             20h                             ; call _Mov10ToOp1
	rst             10h                             ; call _FindSym
	call    _delvar                 ; destroys the variable
	Ret

; ---------------------------------------------------

RecupChaine:
	ld              hl, $C089                       ; OP1 adress
    ld          (hl), $0C               ; variable type
    inc         hl                      ; next byte
    ld          (hl), $06               ; Name length
    inc         hl                      ; Now hl points to the variable name space in OP1
    push        hl                      ; save this 
    ld          hl, NomVar                      ; hl points to the real variable name
    pop         de                      ; get the saved hl in de
    ld          bc, 6                   ; got to copy the 6 characters
    ldir                                ; what it is done with ldir
	rst     10h                                     ; call _FindSym
	jp              c, _jforcecmdnochar		; if error, exits
	ld              a, b                            ; a = b
	ex              de, hl                          ; de = hl and hl = de
	call    $4633   			; undocumented but used for the ram page location
								; I recently saw a definition for that call
; what it doese is very simple. its puts the page and the offset in this page for a
; variable absolutely pointed by bde. at the return a contains the ram page and hl the 
; offset
	set     6, a                            ; sets a register 6th bit to say its a ram page
		push    hl                              ; saves the offset
		ld              hl, PageMem
		ld              (hl), a					; saves the page number
		pop             hl						; restores the offset
	out     (5), a                  			; puts the first page in place
	inc     a                                       ; add 1 to a to point the next page
	out     (6), a								; puts this page in place
	nop											; waits port reacts
; in put the two pages contiguous cause a string can (?) begin into a page and ends into 
; another (must be but...)

	ld              bc, $4000                       ; bc = $4000 (length of a page)
	or              a                               ; sets carry to 0
	sbc     hl, bc                          		; hl = hl - bc
; must decrement hl by $4000 cause the $4633 function considers you put the ram page in the good
; location, meaning at $8000. but for the reason explained, i put it at $4000 so i have to 
; decrement hl by $4000

	ld              c, (hl)
	Inc             hl
	ld              b, (hl)                         ; so we got bc = string length
	Inc             hl							
; that's done as this cause the first two bytes are the string length 
		push    hl                              ; saves hl
		ex              de, hl
		ld              hl, Decalage
		ld              (hl), e
		Inc             hl
		ld              (hl), d
		pop             hl

	add             hl, bc                          ; hl = hl + string length
		ld              (FinChaine), hl
		push    hl
		ld              bc, 2
		ld              de, OctetsPerdus        ; saves the future 2 lost bytes
		ldir
		pop             hl						; gets hl back
	ld              (hl), 0
	inc             hl
	ld              (hl), 0                         ; double 0 for string end
	call    RetourPageNormales				; gets normal pages back
	ret

;------------------------------------------------------
; this formats the string to be displayed into multiple lines. a bit too hard to explain today.
; i will do this comment part during holidays perhaps
FormateChaine:
	ld              hl, numligne
	ld              (hl), 1
	ld              hl, $0000
	ld              (_pencol), hl
	ld              hl, Decalage
	call    _ldhlind
deb:
	push    hl
	ld              hl, NumLigne
	ld              e, (hl)
	inc             hl
	ld              d, (hl)
	ld              hl, Tabligne-2
	add             hl, de
	add             hl, de                                  ; so hl = Tabligne - 2+ 2*numligne
	pop             bc                                              ; so bc = copying address
	ld              (hl), c
	inc             hl
	ld              (hl), b
	ld              h, b
	ld              l, c    
Boucle:
		call    ChargePageMem
		ld              a, (hl)
		push    af                                      ; saves founded value
		call    RetourPageNormales
		pop             af                                      ; gets character value
		cp              0
		jp              z, saut                         ; if its 0 jump
		cp              185
		jp              z, saut                         ; if a = '¿' jump
; the ¿ (inverted ?) character is used to indicates that a line is terminated.
; useful for multiple empty lines, this prevents you from entering thousands of spaces
		push    af
		ld              a, (_pencol)
		ld              b, a
		pop             af
		push    bc
	Call    _vputmap
		pop             bc
	Inc             hl                                      ; next byte in string
	ld              a, (_pencol)
	cp              b
	jp              nz, Boucle                      ; if the cursor moved, continue
Boucle2:
	dec             hl
	dec             c
		call    ChargePageMem
		ld              a, (hl)
		push    af                                      ; save founded value
		call    RetourPageNormales
		pop             af                                      ; gets character value
	cp              32                                      ; a space ?
	jr              nz, Boucle2                     ; No, continue
	ld              a, (NumLigne)					; put numligne in a
Saut:
	ld              b, 0
	or              a                                       ; carry set to 0
		push    af                                      ; saves a value
		Call    ChargePageMem
		ld              (hl), 0
		call    RetourPageNormales
		pop             af                                      ; gets a value back
	Inc             hl
	push    hl                                      ; gets where we must cut the string
	ld              hl, Numligne            ; gets current line number
	inc             (hl)                            ; increments it
	ld              hl, $0000
	ld              (_pencol), hl           ; reset of the coordinates
	call    _clrLCD                         ; clear screen
	pop             hl                                      ; gets cut adress bakc
		Call    ChargePageMem
		ld              a, (hl)
		push    af                                      ; saves founded value
		call    RetourPageNormales
		pop             af                                      ; gets charcater value back
	cp              0                                       ; is it a zero char
	jp              nz, Deb                         ; no so continue cause not end string
	ld              hl, Numligne
	dec             (hl)                            ; Puts numligne
	ret

;-----------------------------------------------------------------
; this displays the formated string
;
Affiche:
	push    af
	ld              b, a                            ; b = last line number
	cp              9
	ld              a, 1
	jp              M, Suite1                       ; a - 9 was negative so we jump
	ld              a, b
	sub             9
	cp              0
	inc             a
	jp              nz, Suite1
	ld              a, 1
Suite1:                                                 ; a = 1st line number
	ld              hl, TabLigne - 2
	ld              d, 0
	ld              e, b
	add             hl, de
	add             hl, de                          ; hl = tabligne - 2 + b * 2
	ld              c, a
	ld              a, b
	ld              b, c                            ; so a and b are exchanged
	sub             b                                       ; a contains line number
	ld              b, a                            ; b = a
	ld              a, 0
	add             a, b
	add             a, b
	add             a, b
	add             a, b
	add             a, b
	add             a, b                            ; a = 6 * b
	Inc             b
LabelBcl:
		push    bc
		ld              (_penrow), a
		push    af
		ld              a, $00
		ld              (_pencol), a
		push    hl
		call    _ldhlind                ; hl = beginning string adress
			Call    ChargePageMem
			ld              de, Chaine
			ld              bc, 130                         ; 130 characters to copy
			ldir                                            ; copying
			call    RetourPageNormales
		ld              hl, chaine
		call    _vputs                          ; displays
		ld              a, 128
		ld              hl, _pencol
		ld              b, (hl)
		sub             b                               ; so we got a = 128 - _pencol
		ld              b, a                            ; so we get b = 128 - _pencol
BoucleAff:
			ld              a, 32
			call    _vputmap
		djnz    BoucleAff
		pop             hl
		dec             hl
		dec             hl                                      ; we get then hl = hl - 2
		pop             af
		sub             6                                       ; a = a - 6
		pop             bc
	djnz    LabelBcl
	pop             af
	ret

;----------------------------------------------------------------------
ChargePageMem:
	ld              a, (PageMem)
	out             (5), a                          ; loads the ram pages of the variable
	Inc             a
	out             (6), a
	ret

;----------------------------------------------------------------------
RetourPageNormales:
	ld              a, %00001101            ; puts back the standard pages (with the calls)
	out     (5), a
	ld              a, %01000001
	out     (6), a
	ret     

;--------------------------------------------------------------------
; this  displays the menu. I now know i could have done it by some standard calls.
; but it was still in developpment when i needed this viewer
;
AfficheMenu:
	ld              de, $FF80
	ld              hl, ImgMenu
	ld              bc, 128
	ldir 
	ld              hl, $3A04
	ld              (_pencol), hl
	ld              hl, Page
	call    _vputs
	ld              a, 31
	call    _vputmap
	ld              hl, $3A1D
	ld              (_pencol), hl
	ld              hl, Page
	call    _vputs
	ld              a, 30
	call    _vputmap
	ld              hl, $3A51
	ld              (_pencol), hl
	ld              hl, Prec
	call    _vputs
	ld              hl, $3A6C
	ld              (_pencol), hl
	ld              hl, Exit
	call    _vputs
	ret
	

;*************************************************************
; VARIABLE SPACE
; this is safer to put variables here cause I use OP routines which destroys the 'free' ram
; locations sometimes indicated in some sources
NumLigne:
	.dw 0
PageMem:
	.db 0
Decalage:
	.dw 0
Avant:
	.db 0
OctetsPerdus:
	.dw 0
FinChaine:
	.dw 0
Var:
	.db $0C,$06 
NomVar:
	.db "CHAINE",0,0,0
Page:
	.text "Page"
Prec:
	.text "Prev"
Exit:
	.text "Exit"
ImgMenu:
	.db %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111110
	.db %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
	.db %11000000, %00000000, %00000000, %01100000, %00000000, %00000000, %00110000, %00000000, %00000000, %00011000, %00000000, %00000000, %00001100, %00000000, %00000000, %00000110
Chaine:
	.db "                                                                 "
	.db "                                                                 "
TabLigne:
	.dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	.dw 0,0,0,0,0,0,0,0,0,0,0,0

.end
Warning
Could not process part with given Content-Type: application/x-zip-compressed; name="AffiUK.zip"

Follow-Ups: