Printing 6 lines of text in 4-planes font in less than 1 vbl

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Post Reply
User avatar
YQN
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 125
Joined: Sat Jul 22, 2017 6:01 pm
Location: Meaux
Contact:

Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by YQN »

Hello and welcome to another n00b thread!

I thought it would be possible to do that, doesn't sound too extreme but maybe that's more advanced than I thought? Or It's just not possible and should be stored in memory beforehand? I replaced all the mulu's and divu's with bit shifting but it makes no difference...

Right now I was thinking I might use 2 screens and write in one while I display the other one but I wanted to know if I'm doing something stupid in my code, and I'm trying to not use up all the RAM. Here's my code (I removed most of what was not relevant):

Code: Select all

; Music disk by YQN

show_vbl		equ	1

INTRO_WAIT		equ	2			; number of vbl before intro update
WINDOW_HEIGHT	equ	100
HEIGHT			equ	100			; half screen

; ascii substitutions
CR			equ 13
LF			equ	10

	section	text
	
********************** GWEM WANTS MEMORY FOR THE DIGIDRUMS *********************
	
		move.l	4(sp),a5			;address to basepage
		move.l	$0c(a5),d0			;length of text segment
		add.l	$14(a5),d0			;length of data segment
		add.l	$1c(a5),d0			;length of bss segment
		add.l	#$100,d0			;length of basepage
		add.l	#$1000,d0			;length of stackpointer
		move.l	a5,d1				;address to basepage
		add.l	d0,d1				;end of program
		and.l	#-2,d1				;make address even
		move.l	d1,sp				;new stackspace

		move.l	d0,-(sp)			;mshrink()
		move.l	a5,-(sp)			;
		move.w	d0,-(sp)			;
		move.w	#$4a,-(sp)			;
		trap	#1				;
		lea	12(sp),sp			;

*********************** INITS **************************
	
		jsr initialise
		
		lea.l	font+2,a0
		movem.l	(a0),d0-d7
		movem.l	d0-d7,$ff8240
	
*;	BUFFERING
		move.l	#screen1,d0		;put screen1 address in d0
		clr.b	d0				;put on 256 byte boundary	
		move.l	d0,next			;store address
		add.l	#32000,d0		;next screen area
		move.l	d0,last			;store address
*;
	
		; create fonts
		lea.l	font+34,a0
		lea.l	font+34+24*160,a2
		move.l	#font_data,a1
		move.l	#intro_font_data,a3
		move.l	#59,d0					; 120 chars: 60 clusters of 2 chars
.chars		
.q 		set 0
		rept 8
		move.b	.q(a0),(a1)+			; 1 plane font
		move.b	.q+0(a2),0(a3)			; 4 planes font
		move.b	.q+2(a2),1(a3)			;
		move.b	.q+4(a2),2(a3)			;
		move.b	.q+6(a2),3(a3)			;
		add.l	#4,a3
.q		set		.q+160
		endr
.q 		set 1
		rept 8
		move.b	.q(a0),(a1)+			; 1 plane font
		move.b	.q+0(a2),0(a3)			; 4 planes font
		move.b	.q+2(a2),1(a3)			;
		move.b	.q+4(a2),2(a3)			;
		move.b	.q+6(a2),3(a3)			;
		add.l	#4,a3
.q		set		.q+160
		endr
		add.l	#8,a0
		add.l	#8,a2
		move.l	d0,d1
		divu.w	#20,d1
		swap	d1
		tst.w	d1
		bne		.suite
		add.l	#160*7,a0
		add.l	#160*7,a2				; NEW LINE
.suite
		dbra	d0,.chars
	
		; inits
		clr.w	intro_step
		move.l	#intro_txt_1,d0
		jsr		txt_2_half_screen
		
		
******************************* steal VBL *******************************

		move.w	sr,d0				;store sr
		move.w	#$2700,sr			;stop all ints
		move.l  $70.w,old_70			; backup $70
		move.l  #main_vbl,$70.w			; ----------------- OCCUPY VBL !!!!!!!!!!!!!!!!!!!!!!!!!!!!
		move.w	d0,sr				;restore sr


*************************************** THE_LOOP ****************************

the_loop
		cmp.b	#$39,$fffffc02.w		;check for space
		bne.s	the_loop

		

		
****************************************** EXITS ******************************
	
		move.l	old_70,$70

		jsr restore
	
		clr.l	-(a7)
		trap	#1					; GEMDOS

	
*******************************************************************************
	

********************************** VVV BBB LLL *******************************
	
main_vbl
		movem.l	d0-d7/a0-a6,-(sp)
		
		move.l	next,d0
		clr.b	$ffff820d		;clear STe extra bit	
		lsr.l	#8,d0		
		move.b	d0,$ffff8203	;put in mid screen address byte
		lsr.w	#8,d0
		move.b	d0,$ffff8201	;put in high screen address byte
		
		move.l	last,a0
		move.l	next,a1			; load screens
		move.l	a1,last			; and flip them for next time around
		move.l	a0,next			; double buffering :)
		
		jsr		update_intro
		
		movem.l	(sp)+,d0-d7/a0-a6
		rte
	
	
	
************************************ INTRO ****************************************

update_intro:
		move.w	intro_wait_counter,d0			; vbl delay between plane updates
		tst.w	d0
		beq.s	.proceed
		sub.w	#1,intro_wait_counter
		bra.w	.done
		
.proceed
		move.w	#INTRO_WAIT,intro_wait_counter	; reset wait counter
		
		move.l	next,a0
		move.l	last,a1
		move.l	#half_screen,a2
				
		clr.l	d0
		move.w	line_counter,d0		; go to current line address
		clr.l	d4
		move.w	d0,d4					; multiply by 160 (2^5+2^7)
		asl.l	#5,d0					;
		asl.l	#7,d4					;
		add.l	d4,d0					;
		add.l	d0,a2
		add.l	#50*160,d0			; line where to start the drawing
		add.l	d0,a0				;
		add.l	d0,a1				;
		
		move.w	line_counter,d2

		move.l	#19,d0				; 20 clusters
.clusters
		cmp.w	#HEIGHT,d2
		bpl		.no_1st_plane
		move.w	(a2),(a0)
		move.w	(a2),(a1)
.no_1st_plane

		cmp.w	#1,d2
		bmi		.no_2nd_plane
		cmp.w	#HEIGHT+1,d2
		bpl		.no_2nd_plane
		move.w	-160+2(a2),-160+2(a0)
		move.w	-160+2(a2),-160+2(a1)
.no_2nd_plane

		cmp.w	#2,d2
		bmi		.no_3rd_plane
		cmp.w	#HEIGHT+2,d2
		bpl		.no_3rd_plane
		move.w	-160*2+4(a2),-160*2+4(a0)
		move.w	-160*2+4(a2),-160*2+4(a1)
.no_3rd_plane

		cmp.w	#3,d2
		bmi		.no_4th_plane
		cmp.w	#HEIGHT+3,d2
		bpl		.no_4th_plane
		move.w	-160*3+6(a2),-160*3+6(a0)
		move.w	-160*3+6(a2),-160*3+6(a1)
.no_4th_plane

		cmp.w	#WINDOW_HEIGHT,d2				; erase?
		bmi		.dont_erase
		
		cmp.w	#WINDOW_HEIGHT+HEIGHT,d2
		bpl		.plane_3
		move.l	#-WINDOW_HEIGHT*160+6,d1
		clr.w	(a0,d1)					; 4th plane
		clr.w	(a1,d1)					; 4th plane
		
.plane_3
		cmp.w	#WINDOW_HEIGHT+1,d2
		bmi		.plane_2
		cmp.w	#WINDOW_HEIGHT+1+HEIGHT,d2
		bpl		.plane_2
		move.l	#-(WINDOW_HEIGHT+1)*160+4,d1	; 3rd plane
		clr.w	(a0,d1)
		clr.w	(a1,d1)
		
.plane_2
		cmp.w	#WINDOW_HEIGHT+2,d2
		bmi		.plane_1
		cmp.w	#WINDOW_HEIGHT+2+HEIGHT,d2
		bpl		.plane_1
		move.l	#-(WINDOW_HEIGHT+2)*160+2,d1	; 2nd plane
		clr.w	(a0,d1)
		clr.w	(a1,d1)
		
.plane_1
		cmp.w	#WINDOW_HEIGHT+3,d2
		bmi		.dont_erase
		cmp.w	#WINDOW_HEIGHT+3+HEIGHT,d2
		bpl		.dont_erase
		move.l	#-(WINDOW_HEIGHT+3)*160,d1		; 1st plane
		clr.w	(a0,d1)
		clr.w	(a1,d1)
		
.dont_erase
		add.l	#8,a0
		add.l	#8,a1
		add.l	#8,a2
		dbra	d0,.clusters
		
		add.w	#1,line_counter
		move.w	line_counter,d0
		cmp.w	#HEIGHT+WINDOW_HEIGHT+3,d0
		bne.s	.done
		
		move.w	#0,line_counter			; reset counter
		add.w	#1,intro_step
		
		cmp.w	#1,intro_step			; test intro step
		bne.s	.not_2nd
		move.l	#intro_txt_2,txt_pointer	; update txt address
		jsr		txt_2_half_screen
		bra.s	.done
.not_2nd
		cmp.w	#2,intro_step
		bne.s	.done
		move.l	#intro_txt_3,txt_pointer
		jsr		txt_2_half_screen

.done		
		rts

		
		
********************************* TEXT ********************************


txt_2_half_screen:						; copies txt to intro half screen
		ifne	show_vbl
		move.w	#$505,$ff8240	; vbl time monitoring
		endc

		clr.w	cursor_x
		clr.w	cursor_y
		
.loop
		clr.l	d0
		move.l	txt_pointer,a6			; retrieve address of text 
		move.b	(a6),d0
		tst.b	d0
		beq.w	.done					; exit if 0

		cmp.b	#CR,d0					; test if return
		bne.s	.not_cr
		clr.w	cursor_x
		add.l	#1,txt_pointer
		bra.s	.loop
.not_cr

		cmp.b	#LF,d0					; test if line feed
		bne.s	.not_lf
		add.w	#1,cursor_y
		add.l	#1,txt_pointer
		bra.s	.loop
.not_lf

		sub.b	#$20,d0					; remove ascii offset
		asl.l	#5,d0					; multiply by 32 (4*8 bytes per char)
		move.l	#intro_font_data,a2
		add.l	d0,a2
		
.offset
		clr.l	d3
		move.w	cursor_x,d3
		lsr.l	#1,d3					; divide by 2 to get cluster position
		asl.l	#3,d3					; multiply by 8 (8 bytes per cluster)
		move.l	#half_screen,a1
		add.l	d3,a1
		
		clr.l	d3
		move.w	cursor_y,d3
		asl.w	#3,d3					; multiply by 8 (lines per char)
		move.w	d3,d4					; multiply by 160 (2^5+2^7)
		asl.l	#5,d3					;
		asl.l	#7,d4					;
		add.l	d4,d3					;
		add.l	d3,a1					; offset
		
		move.l	#7,d1
.lines
		clr.l	d3
		move.w	cursor_x,d3
		asr.w	#1,d3					; test if even
		bcs.s	.odd

		move.b	(a2)+,(a1)
		move.b	(a2)+,2(a1)
		move.b	(a2)+,4(a1)
		move.b	(a2)+,6(a1)
		bra.s	.proceed
		
.odd
		move.b	(a2)+,1(a1)
		move.b	(a2)+,3(a1)
		move.b	(a2)+,5(a1)
		move.b	(a2)+,7(a1)

.proceed
		add.l	#160,a1
		dbra	d1,.lines
		
		add.l	#1,txt_pointer
		add.w	#1,cursor_x
		bra		.loop
.done		
		ifne	show_vbl
		move.w	#0,$ff8240		; restore bg color
		endc

		rts
	
dummy:
		rts




******************************************************************************
	
	include	'initlib2.s'

*******************************************************************************

	section	data

old_70			dc.l	0
intro_wait_counter
		dc.w	INTRO_WAIT
line_counter
		dc.w	0

font
	incbin	'0182_.PI1'
	even
	
next	dc.l	0
last	dc.l	0

intro_txt_1
	DC.B	LF,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	0
	even
intro_txt_2:
	dc.b	LF,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	0
	even
intro_txt_3:
	dc.b	LF,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	"blahblahblahblahblahblahblahblahblahblah",CR,LF
	dc.b	0
	even

cursor_x	dc.w	0
cursor_y	dc.w	0

txt_pointer	dc.l	intro_txt_1		; for printing whole msg at once
	even

***********************************************************************************

	section bss
	
	ds.b	256
screen1	ds.b	32000
screen2	ds.b	32000
	even
	
half_screen
		ds.b	16000
font_data		ds.b	94*8		; 94 chars * 8 bytes
intro_font_data	ds.b	94*8*4		; 94 chars * 8 bytes * 4 planes

intro_step		ds.w	1
Please enlighten me! Thx!
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

Haha edit. Didn't read your code right ;)

Are you using move.b to draw to screen?
User avatar
YQN
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 125
Joined: Sat Jul 22, 2017 6:01 pm
Location: Meaux
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by YQN »

yes because one char is 8 pixels wide so 1 byte on each plane
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

Hey, ok, so, this is inefficient as you've realised (obviously!). If you're writing four bitplane data to screen, you need to be using move.l or movem.l for optimal efficiency. So in this case, you need to come up with a way to organise your source data/font more efficiently to allow this.

A couple of ideas.

1) You could hold two versions of your font but as 16 pixel wide characters. In version 1, the fonts take up the left hand eight pixels of your 16 pixel block. Version 2 is shifted by eight pixels to the right.

For each line of each pair of letters/16 pixels to be written to screen, you movem the appropriate version 1 character, and then or in the second character from your version 2 table, and then write the screen as two longs with move.l. I haven't worked it out but I think this would still be faster than what you're doing at the moment.

2) If memory is not an issue, you could create a table of every combination of pairs of characters in your font. Rather than looking up the next char with a move.b from your message, you then use move.w to read a pair and look up the matching 16 pixel wide pair from your table, and then write straight to screen. This would be fast.

3) Or, you generate all your text using your current routine at initialisation to a buffer, and then just write straight to screen when you need it during runtime. This would be fast and easy. I'd probably do it this way, unless you have kbs of text that would take up screens and screens of memory....

Golden rule - cut the number of instructions you are doing in your runtime/mainloop by doing as much as you can at initialisation...
User avatar
YQN
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 125
Joined: Sat Jul 22, 2017 6:01 pm
Location: Meaux
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by YQN »

Ok I'll use a bit more memory, I think I can afford that, thx Tom!
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

Great. If you're using (3), remember that movem.l is your best friend....
User avatar
prog99
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 121
Joined: Thu Jun 19, 2003 8:08 pm
Location: Edinburgh
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by prog99 »

My hazy memory suggests movep may well be your friend here?
Assuming your not targeting anything esoteric of course as it got dropped from some 68k models.
All my real skills are undervalued
joska
Hardware Guru
Hardware Guru
Posts: 4720
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by joska »

Optimizing code at this level is far from my thing, so these tips are far from the most efficient ways to do it. But they are rather simple.

1. Preprocess as much as possible. The text should be pre-processed to a list of pointers to the font characters itself. Then you don't have to do this for every character you draw. Same with screen locations, precalculate lookup-tables to avoid unneccessary calculations at "run-time".
2. Optimize writing. Instead of copying bytes from memory to memory, you can read them from memory into one or two registers, and write everything with a single movem.l or movep.l depending on implementation. This way you will write two character-lines with a single instruction.
3. Optimize reading by organising the font bitmap correctly, avoiding byte reads.

With both (2) and (3) movep is your friend in this case. With movep you can put all four bitplanes of a byte-wide character into a single longword.

Code: Select all

movep.l $ddccbbaa,(a0)
...will write $aa to 0(a0), $bb to 2(a0), $cc to 4(a0) and $dd to 6(a0). So with a properly organized font bitmap you can read an entire character line into a register with a single instruction, and write it directly to the screen with another single instruction.

Code: Select all

; a0 points to font bitmap
; a1 points to screen
; Given an 8x8 font in 4 bitplanes and ST low screen this will copy an entire character to screen.
move.l (a0)+,d0
movep.l d0,0(a1)
move.l (a0)+,d0
movep.l d0,160(a1)
move.l (a0)+,d0
movep.l d0,320(a1)
move.l (a0)+,d0
movep.l d0,480(a1)
move.l (a0)+,d0
movep.l d0,640(a1)
move.l (a0)+,d0
movep.l d0,800(a1)
move.l (a0)+,d0
movep.l d0,960(a1)
move.l (a0)+,d0
movep.l d0,1120(a1)
As prog99 suggests this instruction is gone on the 060, but on the CT60 it is emulated so the code will work anyway.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
mlynn1974
Captain Atari
Captain Atari
Posts: 362
Joined: Mon Mar 03, 2008 10:33 pm
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by mlynn1974 »

It might be an idea to precalculate a tab of y-offsets for the screen so you don't need to do 160(a1) etc.
Is the font stored one byte per character per bitplane? It might be a good idea to preshift the font with each character padded out to 16 bits, so that any 2 character combination can be made before outputting to the screen.

Then you could 'or' the second half of the 2 character pair and output one line for 2 characters at a time:
movem.l d0-d3,(a1)+

If possible could you attach the source code and graphics?
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).
User avatar
MiggyMog
Atari Super Hero
Atari Super Hero
Posts: 905
Joined: Sun Oct 30, 2005 4:43 pm
Location: Scotland

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by MiggyMog »

Maybe it is already dealt with but it occurs to me that an 8 pixel wide font is going to use maximum of 8 colours/ 3 planes per line so there may be a further optimisation there?
('< o o o o |''| STM,2xSTFM,2xSTE+HD,C-Lab Falcon MK2+HD,Satandisk,Ultrasatandisk,Ethernat.
joska
Hardware Guru
Hardware Guru
Posts: 4720
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by joska »

mlynn1974 wrote: Wed Sep 02, 2020 9:30 pm It might be an idea to precalculate a tab of y-offsets for the screen so you don't need to do 160(a1) etc.
This is precalculation :) The offset to the next screenline is hardcoded into the instruction rather than calculated for each character line you draw. This saves you time, as you don't need to read the offset and then apply it to every character line.
mlynn1974 wrote: Wed Sep 02, 2020 9:30 pm Is the font stored one byte per character per bitplane? It might be a good idea to preshift the font with each character padded out to 16 bits, so that any 2 character combination can be made before outputting to the screen.

Then you could 'or' the second half of the 2 character pair and output one line for 2 characters at a time:
movem.l d0-d3,(a1)+
True, this saves you one write per character line. But it adds extra reads as half the font data you read will be worthless zeros, and an extra operation in ORing the registers. For this particular case I don't think there is a more efficient EASY solution than movep.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

If this is for a demo, I think movep is unnecessarily slow... I'd want to be writing to screen with move.l or movem.l. It's the cleanest and most elegant solution code wise, but adds an unnecessary overhead when what is being written to screen is highly predictable...
joska
Hardware Guru
Hardware Guru
Posts: 4720
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by joska »

We don't really know how predictable it is. If it's a 30Kb scrolltext it's not predictable at all. If it's just a menu for a musicdisk then it's probably best to pre-render the entire menu and simply movem it to the screen.

It seems to me that your suggestion will not be faster than the movep solution, despite that movep is slower than movem. If I understand you correctly you would to something like this...

Code: Select all

; a1 points to even character
; a2 points to odd character in shifted character set
; a3 points to screen

movem.l (a1)+,d0-d1
movem.l (a2)+,d2-d3
or.l d2,d0
or.l d3,d1
movem.l d0-d1,offset(a3)
...for each character line. There is one write instruction (one movem instead of two movep) and probably two write cycles less, but the extra cost compared to the movep method is two extra reads and one OR (which also has to be read) per character. That pretty much cancels out the write savings. It's been a loooong time since I counted cycles but I don't think you'll gain much - if any - speed compared to the simpler movep solution.

However, both methods should be able to print six lines of 8x8 characters to the screen in much less than one VBL, especially if the text is converted to a list of fontdata pointers first. Converting from ASCI to fontdata address for each character is probably more costly than the copying.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

Hey,
I'm probably not being clear enough - I was advocating pre-rendering. If he's doing a scrolltext he needs to use a different method entirely but I thought he was just writing chars to screen.

Incidentally in the above example you can skip the second movem read and just use or.l (a2)+, d0 ;)

Tom (crap coder).
User avatar
YQN
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 125
Joined: Sat Jul 22, 2017 6:01 pm
Location: Meaux
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by YQN »

Didn't mean to start a movem/movep debate lol! To make things clear I'm trying to display about 15-18 lines of text as an intro for a music disk, without effects, in 3 parts of 5 to 6 lines each (see attached .tos). I might have to display small graphx as well (static), so I guess I'll go for an extra screen that I'll display one third at a time. Do you guys know how to make sure a program runs on a 520 (besides testing it)? I'm guessing if the executable size + bss section must be under 512k?

Edit: also thx all for your replies!
You do not have the required permissions to view the files attached to this post.
wietze
Captain Atari
Captain Atari
Posts: 328
Joined: Fri Mar 01, 2013 10:52 pm

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by wietze »

Im tempted to just calc out the cpu use for the different approaches ;P

Also, I think this forum needs more of these inspiring questions; its good to see that there are things in the making!

As for your question, yes; to ensure your program runs on 512kb memory, you need to set an upper limit for CODE+DATA+BSS(+SYMBOLS?) that works. Then you need to determine if you want to run the program from TOS or (loading TOS into memory reduces available space for programs to run) or if you want to run it from auto folder (then no TOS loaded in memory, so you have a wee more space). Exact available memory to run from auto depends per ROM version on the machine; but can be generalized.

I assume you have enough pointers to improve the speed of your scroller; if not; Id gladly still perform said cycle counting excersize :)
joska
Hardware Guru
Hardware Guru
Posts: 4720
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by joska »

YQN wrote: Thu Sep 03, 2020 3:27 pm To make things clear I'm trying to display about 15-18 lines of text as an intro for a music disk, without effects, in 3 parts of 5 to 6 lines each (see attached
Had a quick look at it. It's not much text, I would probably just pre-render the whole image off screen first and then copied it to screen.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
mlynn1974
Captain Atari
Captain Atari
Posts: 362
Joined: Mon Mar 03, 2008 10:33 pm
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by mlynn1974 »

Nice program. I think the pre-rendered text would be the fastest. A type routine would be really handy for a demo like the loader on the Whattaheck Demo for instance.

Which assembler do you use? Hisoft Devpac was really the most popular on the ST.
Devpac 2 shows loads of unable to use .local errors. On Devpac 3 there is one "unable to use .local" error but I just had to change .chars to chars and dbra d0,chars and it assembled correctly. Devpac really only uses the .S source code extension not .ASM
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).
User avatar
YQN
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 125
Joined: Sat Jul 22, 2017 6:01 pm
Location: Meaux
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by YQN »

Thx, I'm using notepad++ and vasm, using this toolkit: https://www.chibiakumas.com/68000/68000DevTools.php
ThorstenOtto
Atari God
Atari God
Posts: 1189
Joined: Sun Aug 03, 2014 5:54 pm

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by ThorstenOtto »

wietze wrote: Thu Sep 03, 2020 6:03 pm (+SYMBOLS?)
Symbols don't matter for the memory requirements, TOS will skip them when loading the program. But they take up disk space of course, which may matter when you put it on a floppy.
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

Hey YQN,

Finally checked this out - a nice little dissolve effect!

The implementation you are using does feel quite convoluted though. If your music isn't too timer intensive (HA!- I bet it is ;) ) then I would be tempted to do this with palette switching instead of physically "dissolving" the pixels. To my eye it looks like you're fading/dissolving less than 8 lines per frame - so I'd probably try this (assuming your music is using timers) with having a synclocked six lines of code called off a timer A or B, which changes palette (pregenerated) on each line to achieve the fading effect. You can then move the trigger point of this routine down each frame to achieve the downward fadeout.

If you are using e.g. SID voice, then this may affect sound quality, so may not work. But if it does, it would mean you achieve the same effect in six scanlines rather than 1+ vbl.....

Just a thought.......
User avatar
YQN
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 125
Joined: Sat Jul 22, 2017 6:01 pm
Location: Meaux
Contact:

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by YQN »

thomas3 wrote: Sat Sep 05, 2020 6:56 pm Hey YQN,

Finally checked this out - a nice little dissolve effect!
thx! i tried to make something nice with my limited set of skills :)
The implementation you are using does feel quite convoluted though. If your music isn't too timer intensive (HA!- I bet it is ;) ) then I would be tempted to do this with palette switching instead of physically "dissolving" the pixels. To my eye it looks like you're fading/dissolving less than 8 lines per frame - so I'd probably try this (assuming your music is using timers) with having a synclocked six lines of code called off a timer A or B, which changes palette (pregenerated) on each line to achieve the fading effect. You can then move the trigger point of this routine down each frame to achieve the downward fadeout.

If you are using e.g. SID voice, then this may affect sound quality, so may not work. But if it does, it would mean you achieve the same effect in six scanlines rather than 1+ vbl.....

Just a thought.......
not sure i understand you well...
i'm "fading" 8 lines per frame at most depending on the WINDOW_HEIGHT value, right now it's 4 lines at most with these settings (which make me think that the algorithm could be significantly simplified btw but it's not CPU costly compared to the printing of the chars to the memory, so not high in the priority list). I'm foolishly using 3 timers in the music and I won't learn a new technique right now, i need to get this thing done first! but rasters and timers are definitely in my to do list for the near future! :)
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 161
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Printing 6 lines of text in 4-planes font in less than 1 vbl

Post by thomas3 »

I'm foolishly using 3 timers in the music
Ha, OK, forget my suggestion ;)
Post Reply

Return to “680x0”