5. A text scroller

Hits: 3423

A simple text scroller

More
Tags
Author: aLpHa oNe
Submitted by: musashi9
Date: 2006-02-01 14:26
No tags
 Setting up a simple copperlist + 1 Bitplane + 
; a simple scrolltext. No (c)ode by aLpHa oNe!
; =============================================

	section	flashtro,code_c

	move.l 4.w,a6		; Get base of exec lib
	jsr -132(a6)		; Forbid Multitasking
	lea gfxlib(pc),a1	; Adress of gfxlib string to a1
	jsr -408(a6)		; Call OpenLibrary()
	move.l d0,gfxbase	; Save base of graphics.library
	move.l #bitplane,d0	; Get adress of our bitplane...
	move.w d0,bplptr+6	; ...and set up bitplaneregs in copperlist
	swap d0			;
	move.w d0,bplptr+2	;
	move.l #cop,$dff080	; Set new copperlist

;-------------------------------------------------------------------------
	lea text(pc),a0		; Adress of our text to a0
loop:	bsr.w print		; Call Textroutine
	moveq #8-1,d7		; Scrollcounter (-1 coz of dbf loop)
scroll:	cmp.b #$ff,$dff006	; Wait VBL
	bne.b scroll		;
	lea bitplane+8*50(pc),a1; Scroll area by bitshifting to the left
	move.l #(8*50)/2,d0	; Range to scroll, 8*50 bytes
shift:	roxl.w -(a1)		; divided by 2 coz we shift wordwise
	dbf d0,shift		;
	dbf d7,scroll		; Scroll 8 times by one pixel
	addq.l #1,a0		; Increase Textptr to next letter
	move.b #0,bitplane	; Clear 8 Pixels at bitplanestart
	btst #6,$bfe001		; Left mouse clicked ?
	bne.b loop		; No, continue scrollloop!
;-------------------------------------------------------------------------

	move.l gfxbase(pc),a1	; Base of graphics.library to a1
	move.l 38(a1),$dff080	; Restore old copperlist
	jsr -414(a6)		; Call CloseLibrary()
	jsr -138(a6)		; Permit Multitasking
	moveq #0,d0		; Over..
	rts			; and out!

; Routine which prints one single letter to a fixed point on bitplane.
; A0 = ptr to text

print:	move.b (a0),d3		; Get current letter
	tst.b d3		; End of text reached?
	bne.b noend		; Nah, continue
	lea text(pc),a0		; Otherwise a0 points to start of text again
	move.b (a0),d3		; Get first letter
noend:	lea chartab(pc),a1	; Adress of chartab to a1
	moveq #0,d2		; Counter
search:	cmp.b (a1,d2),d3	; Find letter in chartab
	beq.b foundit		; Letter found? Go on...
	addq.l #1,d2		; ..else increase counter
	bra.b search		; and continue searching
foundit:lsl.l #3,d2		; counter*8 = correct offset to charbuffer
	lea chars(pc),a3	; Address of chars to a3
	add.l d2,a3		; + offset to correct letter
	lea bitplane+48(pc),a2	; Address of bitplane + 48 (right side)
	moveq #8-1,d2		; Height of chars (-1 coz we use dbf loop)
copy:	move.b (a3)+,(a2)	; Copy the letter
	add.l #50,a2		; 
	dbf d2,copy		;
	rts			; Return to where we came from ;)

; Stuff
; *****

cop:		dc.w	$0106,$0000,$01fc,$0000		; AGA compatible
		dc.w	$008e,$1a64,$0090,$ffc4		; Setting up display,
		dc.w	$0092,$0020,$0094,$00d8		; modulo and so on
		dc.w	$0102,$0000,$0104,$0000
		dc.w	$0106,$0000,$0108,$0002
		dc.w	$0120,$0000,$0122,$0000		; Clear spriteptrs
		dc.w	$0124,$0000,$0126,$0000
		dc.w	$0128,$0000,$012a,$0000
		dc.w	$012c,$0000,$012e,$0000
		dc.w	$0130,$0000,$0132,$0000
		dc.w	$0134,$0000,$0136,$0000
		dc.w	$0138,$0000,$013a,$0000
		dc.w	$013c,$0000,$013e,$0000
		dc.w	$0100,$0200			; No Bitplane
		dc.w	$0180,$0000			; Color00 = Black
		dc.w	$0182,$0fff			; Color01 = White

		dc.w	$850f,$fffe			; Wait VPos $85
		dc.w	$0180,$ffff			; Color00 = White
		dc.w	$860f,$fffe			; Wait VPos $86
		dc.w	$0180,$0312			; Color00 = Dark Pink ?
		dc.w	$880f,$fffe			; Wait VPos $88
		dc.w	$0100,$1200			; 1 Bitplane
bplptr:		dc.w	$00e0,$0000			; Adress of bpl
		dc.w	$00e2,$0000
		dc.w	$920f,$fffe			; Wait VPos $92
		dc.w	$0180,$ffff			; Color00 = White
		dc.w	$930f,$fffe			; Wait VPos $93
		dc.w	$0180,$0000			; Color00 = Black
		dc.w	$ffff,$fffe

text:		dc.b	"  simple scroller for flashtro "
		dc.b	"tutorial section without use of"
		dc.b    " the blitter!         ",0

chartab: 	dc.b 	"abcdefghijklmnopqrstuvwxyz!"	; chars as they appear
		dc.b 	"0123456789*-. "		; in our char table

chars:		dc.b	$00,$7C,$E6,$E6,$FE,$E6,$E6,$06	;"A"
		dc.b	$00,$FC,$E6,$FC,$E6,$E6,$FC,$00	;"B"
		dc.b	$00,$7E,$E6,$E0,$E0,$E6,$7E,$00	;"C"
		dc.b	$00,$FC,$E6,$E6,$E6,$E6,$FC,$00	;"D"
		dc.b	$00,$FE,$E6,$F8,$E0,$E6,$FE,$00	;"E"
		dc.b	$00,$FE,$E6,$F8,$E0,$E0,$E0,$E0	;"F"
		dc.b	$00,$7C,$E0,$EE,$E6,$E6,$7E,$00	;"G"
		dc.b	$E0,$E6,$E6,$FE,$E6,$E6,$E6,$06	;"H"
		dc.b	$00,$FE,$38,$38,$38,$38,$FE,$00	;"I"
		dc.b	$0E,$0E,$0E,$0E,$0E,$CE,$7C,$00	;"J"
		dc.b	$E0,$EE,$FC,$F8,$FC,$EE,$E6,$06	;"K"
		dc.b	$E0,$E0,$E0,$E0,$E0,$E6,$FE,$00	;"L"
		dc.b	$00,$C6,$EE,$FE,$F6,$E6,$E6,$06	;"M"
		dc.b	$06,$C6,$E6,$F6,$FE,$EE,$E6,$E0	;"N"
		dc.b	$00,$7C,$E6,$E6,$E6,$E6,$7C,$00	;"O"
		dc.b	$00,$FC,$E6,$E6,$FC,$E0,$E0,$E0	;"P"
		dc.b	$00,$7C,$E6,$E6,$FA,$EC,$76,$06	;"Q"
		dc.b	$00,$FC,$E6,$E6,$FC,$E6,$E6,$06	;"R"
		dc.b	$00,$3C,$70,$3C,$0E,$CE,$FC,$00	;"S"
		dc.b	$00,$FE,$38,$38,$38,$38,$38,$38	;"T"
		dc.b	$E0,$E6,$E6,$E6,$E6,$E6,$7C,$00	;"U"
		dc.b	$E0,$E6,$E6,$E6,$6C,$38,$10,$00	;"V"
		dc.b	$E0,$E6,$E6,$F6,$FE,$EE,$44,$00	;"W"
		dc.b	$C0,$EE,$7C,$38,$7C,$E6,$E6,$06	;"X"
		dc.b	$E0,$E6,$E6,$7C,$38,$38,$38,$38	;"Y"
		dc.b	$00,$FE,$CE,$1C,$70,$E6,$FE,$00	;"Z"
		dc.b	$38,$38,$38,$38,$38,$00,$38,$00	;"!"
		dc.b	$00,$7C,$E6,$EE,$F6,$E6,$7C,$00	;"0"
		dc.b	$00,$F8,$38,$38,$38,$38,$FE,$00	;"1"
		dc.b	$00,$7C,$0E,$7C,$E0,$E6,$FE,$00	;"2"
		dc.b	$00,$FC,$CE,$3C,$0E,$CE,$FC,$00	;"3"
		dc.b	$00,$0E,$1E,$3E,$6E,$FE,$0E,$0E	;"4"
		dc.b	$00,$FC,$E0,$FC,$0E,$CE,$FC,$00	;"5"
		dc.b	$00,$7C,$E0,$FC,$E6,$E6,$7C,$00	;"6"
		dc.b	$00,$FE,$CE,$1C,$38,$38,$38,$38	;"7"
		dc.b	$00,$7C,$E6,$7C,$E6,$E6,$7C,$00	;"8"
		dc.b	$00,$7C,$CE,$CE,$7E,$0E,$7C,$00	;"9"
		dc.b	$00,$66,$FF,$FF,$7E,$3C,$18,$00	;"*"
		dc.b	$00,$00,$00,$00,$FE,$00,$00,$00	;"-"
		dc.b	$00,$00,$00,$00,$00,$38,$38,$00	;"."
		dc.b	$00,$00,$00,$00,$00,$00,$00,$00 ;" "

bitplane:	blk.b	12800,0				; Space for one
							; 400x256 bitplane
							; 50 bytes each row
							; (400 bits/pixels)
gfxlib:		dc.b	"graphics.library",0,0

gfxbase:	dc.l	0
FileDownload: 5. A text scroller
Filesize: 0KB, downloaded 1119 times
Powered by the best online Amiga mod player: FLOD


Some more you may like:
7.Sinus scroller3.Text RoutineText IntroText Scrolly

Comments

Leave a Comment!

Name:
: Use this calculator
Your comment will be available for editing for 10 minutes
2006-02-01 14:47
Avatar

1. bobbearing writes

excellent!
reply
2006-02-01 17:47
Avatar

2. janer writes

dreams come true :) ,.,, great !
reply
2011-12-18 13:05
Avatar

3. Piecia writes

Hello!!!
Does anybony know how to replace blk.b instruction in a simple way ? I have tried to use multipy dc.b " ... " command but it is little unprofessional and it cause extensive growth of the code :)
reply
2011-12-18 22:43
Avatar

4. Mr.Spiv writes

ds.b 12800
reply
2011-12-20 21:23
Avatar

5. Piecia writes

ThankYou Mr.Spiv. I found in one book that command DCB.B could be also use. It depends on type/version assembler. I will check it...
PS
Merry Christmas!!!
reply