[A83] Re: Tilemap/Displaying Pics/ Scrolling Screen
[Prev][Next][Index][Thread]
[A83] Re: Tilemap/Displaying Pics/ Scrolling Screen
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?
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?
And what is 8E29h? Why not just put in a decimal number?
Thanking you in advance,
Maarten
"If I have seen farther than others, it is because I was standing on the
shoulders of giants." - scientist Sir Isaac Newton, in a letter to his
colleague Robert Hooke, February 1676.
>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. Ive seen some
> >tutorials on tilemaps and stuff but they didnt 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 dont
> >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
>
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp