[A83] Re: Tilemap/Displaying Pics/ Scrolling Screen


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

[A83] Re: Tilemap/Displaying Pics/ Scrolling Screen




>From: "Maarten Z." <m021085@hotmail.com>
>
>Ok that even helped me. Thanx.
>But as you tell it now it first puts in a tile, and than scans
>the tilemap where to put it, after the routine has put in the
>tile he takes a new tile and scans the tilemap for that one, and
>so on, am I correct?

No, the routine takes the first byte of the tilemap, which in our case is 0 
and then draws tile number 0. After that the routine takes the next byte of 
the tilemap, which in our case is 1, so it draws tile number 1, and so on.

>I also see you pop reg IX in tyhe beginning, but you haven't stored
>anything in it, so the value will be 0 right?

No, I first push HL, so HL is on top of the stack. If I now pop IX the value 
on top of the stack will come in IX. You can do this with every register.

>And what is 8E29h? Why not just put in a decimal number?

On the 83- that is the address of the scrnBuf. On the 83+ the address should 
be 9340h. Some people call it plotsScreen, others name it gBuf or graphBuf, 
but I prefer scrnBuf, because you use it as a buffer to do all your drawings 
before displaying everything on the screen.

--Tijl Coosemans


> >From: "Tijl Coosemans" <tijlc@hotmail.com>
> >Reply-To: assembly-83@lists.ticalc.org
> >To: assembly-83@lists.ticalc.org
> >Subject: [A83] Re: Tilemap/Displaying Pics/ Scrolling Screen
> >Date: Thu, 09 Aug 2001 19:25:22 +0200
> >
> >
> > >From: "Nick Palladino" <nickps1@hotmail.com>
> > >
> > >Okay, I new to assembly and need some help. I&#8217;ve seen some
> > >tutorials on tilemaps and stuff but they didn&#8217;t help. I want
> > >to know how to
> > >  1. Make and display a picture in assembly.
> > >  2. Make a tilemap to scroll.
> > >Can some one please send me some example code that includes
> > >a real scrolling tilemap that actually works. Thank You.
> > >
> > >P.S could the reply to this be in extensive detail so I don&#8217;t
> > >have to bug anyone else on how to do tilemaps.
> >
> >Extensive detail? Here we go....
> >
> >--------------------------------------------------
> >Chapter I Displaying your own pictures in assembly
> >--------------------------------------------------
> >________________
> >* example code *
> >ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
> >.org progStart
> >
> >	ld	hl,picture	; get the picture
> >	ld	de,8E29h	; is scrnBuf
> >	ld	bc,768		; is number bytes we have
> >	ldir			;   to copy (12*64)
> >	call	fastCopy	; copy scrnBuf to screen
> >	bcall(_getKey)		; wait for a key so we can
> >	ret			;   watch our picture
> >picture:
> >	.db $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
> >	.db $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$55
> >; ..64 lines in total..
> >	.db $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
> >	.db $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$55
> >.end
> >_______________
> >* explanation *
> >ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
> >Each pixel on the screen is represented by one bit. Set a bit and
> >the pixel flashes on. Reset a bit and it goes out. So, to display a
> >picture we first create a bit representation of that picture, copy
> >that data to scrnBuf (or grphBuf or plotsscreen, whatever you call
> >it) and then run a fastCopy routine which just copies the data in
> >the scrnBuf to the screen. So, more in detail, in our case $AA
> >(which is %10101010) would be pixel on, pixel off, pixel on, pixel
> >off, pixel on, pixel off, pixel on, pixel off. If you replace $AA by
> >$FF (is %11111111) you get a full line, and if you replace $AA
> >by ... you get ... etc.
> >
> >--------------------------------------------------
> >Chapter II Displaying a tilemap
> >--------------------------------------------------
> >
> >(I wrote the tilemap routine myself. You may use it of course)
> >________________
> >* example code *
> >ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
> >.org progStart
> >
> >	ld	hl,tilemap	; HL -> tilemap
> >	ld	de,tiles	; DE -> tiles
> >	call	drawTileMap	; draw the tilemap in scrnBuf
> >	call	fastCopy	; copy scrnBuf to screen
> >	bcall(_getKey)		; wait for a key so we can
> >	ret			;   watch our picture
> >
> >drawTileMap:
> >	push	hl
> >	pop	ix
> >	ld	hl,8E29h
> >	ld	bc,8*256+12
> >drawTileMapLoop:
> >	push	bc
> >	ld	b,c
> >drawLineLoop:
> >	push	bc
> >	push	de
> >	push	hl
> >	ld	h,0
> >	ld	l,(ix)
> >	inc	ix
> >	add	hl,hl
> >	add	hl,hl
> >	add	hl,hl
> >	add	hl,de
> >	ex	de,hl
> >	pop	hl
> >	ld	b,8
> >drawTileLoop:
> >	ld	a,(de)
> >	ld	(hl),a
> >	inc	de
> >	ld	a,b
> >	ld	b,0
> >	add	hl,bc
> >	ld	b,a
> >	djnz	drawTileLoop
> >	ld	de,-(8*12)+1
> >	add	hl,de
> >	pop	de
> >	pop	bc
> >	djnz	drawLineLoop
> >	ld	c,7*12
> >	add	hl,bc
> >	pop	bc
> >	djnz	drawTileMapLoop
> >	ret
> >
> >tilemap:
> >	.db	0,1,0,2,0,1,0,2,0,1,0,2
> >	.db	1,0,2,0,1,0,2,0,1,0,2,0
> >	.db	0,1,0,2,0,1,0,2,0,1,0,2
> >	.db	1,0,2,0,1,0,2,0,1,0,2,0
> >	.db	0,1,0,2,0,1,0,2,0,1,0,2
> >	.db	1,0,2,0,1,0,2,0,1,0,2,0
> >	.db	0,1,0,2,0,1,0,2,0,1,0,2
> >	.db	1,0,2,0,1,0,2,0,1,0,2,0
> >tiles:
> >	.db	0,0,0,0,0,0,0,0
> >
> >	.db	00000000b
> >	.db	00011100b
> >	.db	00111110b
> >	.db	01101011b
> >	.db	01111111b
> >	.db	01011101b
> >	.db	00100010b
> >	.db	00011100b
> >
> >	.db	00000000b
> >	.db	00011100b
> >	.db	00111110b
> >	.db	01101011b
> >	.db	01111111b
> >	.db	01100011b
> >	.db	00111110b
> >	.db	00011100b
> >
> >.end
> >_______________
> >* explanation *
> >ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
> >The tilemap routine uses HL and DE as input. HL must point to the
> >tilemap itself and DE to the tiles you want to use. Then the tilemap
> >routine scans the whole tilemap. For each byte it draws that tile,
> >but keep in mind that it starts with 0. So 2 means it takes the 3th
> >tile and so on. And so it fills the whole screen. This tilemap
> >routine draws 8*8 tiles, so the tilemap itself must be 12*8 to fit
> >on a 96*64 screen.
> >
> >===================================================================
> >
> >I know you're desparate to know scrolling and smooth scrolling, but
> >if you already understand this I think you should be capable of
> >understanding a tutorial about that.
> >
> >Hope this helps you a lot already,
> >
> >	Tijl Cosemans


_________________________________________________________________
Download MSN Explorer gratis van http://explorer.msn.nl/intl.asp




Follow-Ups: