View Single Post
Old 21 May 2011, 21:57   #21
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
From the original post I got that you want a screen buffer to do graphics in? But also that you want to learn hardware and aren't quite at the stage where you do advanced routines? (Just tell me if I got you wrong.)

You can do all that with graphics.library, check for example SystemStartup.S in the Examples dir on any Asm-One disk image.

(I'm assuming you're on Workbench 1.2-3.1, although library coding on later OS versions shouldn't be too cumbersome.)

But if you want to do it the hardware way (see NonSystemStartup.S on a similar such disk image ), you do pretty much what you did above, just start a copper and change some colors, then read up on the bitplane pointer & modulo registers and point them (with the copper) to some free (or allocated by you) area of memory that you can poke with pixels But you should turn off some interrupts to prevent the OS from regularly resetting the display, so you can see *your screen* all the time. A startup source does that for you.

You still need graphics.library (but only to restore the system copper (for the assemblers that don't do it for you)), that's what Stingray's startup 'exit code' does. His startup should be a good start for experimenting, you'll get the hang of what his code does later on.

Going OS or going hardware... it all boils down to what you want to code later. If the programs are supposed to be 'Workbench icons programs', go with OS programming.

I hope this gives a sort of outline to getting started.

(If you do plan to go hardware I recommend Asm-One, since it has a good debugger and is more made for HW programming than many others. I use V1.20.)

Once you have a copper pointing to some screen bitplanes, you can just fill that memory area with zeroes to clear it and then copy bytes or something from a font converted to raw to write text on it.

Here's an example: (All from memory so may have errors. But I don't think so. I have ECC.)


Code:
s=$70000	;screen start
e=s+320/8*256	;1 bitplane 320x256 resolution
;----insert at start of copper
	dc.w $e0,s/65536	;addr hi word
	dc.w $e2,s&65535	;addr lo word
	dc.w $108,0		;modulo
	dc.w $10a,0		;modulo
	dc.w $8e,$2881		;upper left corner
	dc.w $90,$28c1		;lower right corner
	dc.w $92,$38		;left edge
	dc.w $94,$d0		;right edge
	dc.w $100,$1200		;1 bitplane, color burst enabled
	dc.w $180,0		;black background
	dc.w $182,$f00		;red 'ink' color
;----------
And a Speccy style clearscreen (blit is faster once you learn it)

Code:
	move.l SP,a0		;save stack pointer
	move.l #0,d0		;fill-value
	lea e,SP		;point to end of screen
	REPT (e-s)/4		;repeat "screensize in bytes divided by four since we poke longwords" times
	move.l d0,-(SP)
	ENDR
	move.l a0,SP		;restore
Don't use delays; after you have initialized your screen and before the exit-code that restores it, insert

Code:
waitmouse:
	btst #6,$bfe001
	bne waitmouse

Now go bang the hardware, hehe.

Last edited by Photon; 21 May 2011 at 22:34.
Photon is offline  
 
Page generated in 0.04307 seconds with 11 queries