[A83] Re: A Routine To Display Big Sprites
[Prev][Next][Index][Thread]
[A83] Re: A Routine To Display Big Sprites
Thanx Tijl those routines are great!
>From: Tijl Coosemans <tijl.coosemans@mail.be>
>Reply-To: assembly-83@lists.ticalc.org
>To: assembly-83@lists.ticalc.org
>Subject: [A83] Re: A Routine To Display Big Sprites
>Date: Wed, 12 Sep 2001 21:44:03 +0200
>
>
>To have text displayed after you used grbufcpy or fastcopy, you must either
>draw the text every time you copied the graph buf to the screen, or, you
>make sure the text is drawn in the graph buf and gets copied to the screen
>together with all the other stuff you've drawn in it. The latter is of
>course the best solution. The first one would cause flicker because the
>text gets removed, redrawn,removed,...
>To have _vputs draw a text string in graph buf instead of on the screen,
>you set 7,(iy+20). Afterwards you res 7,(iy+20), so that _vputs draws back
>to the screen. Otherwise the TIOS wouldn't work well.
>
>Next thing I changed in your source code was the way you draw a line.
>Because it is a horizontal line, it is far more easier and a lot faster to
>get the address in the graph buf of where the row starts. Each row is 12
>bytes and thus you just need to multiply the row you want with 12, and add
>that number to the start address of the graph buffer. Then you just load 12
>bytes (is a full row) with %11111111, so each pixel in that row is set.
>
>To draw your sprite I took the vnDrawPicture routine (from Venus), which
>draws a variable size sprite on the screen. It has the following inputs.
>
> input: b = height (in pixels)
> c = width (in bytes)
> h = x-coordinate
> l = y-coordinate
> ix -> picture data
>
>To speed things up, I also included a fastCopy routine. This should be way
>faster then the _grbufcpy_v routine.
>
>Finally, because there isn't any limit to your shipx value, it will count
>up until it reaches 0 again. Because a screen is only 96 pixel, an x-value
>of, let's say 100, will cause your sprite to be drawn on the next line.
>
>--Tijl Coosemans
>
>.NOLIST ;Necessary stuff,
>#define end .end
>#define END .end
>#define equ .equ
>#define EQU .equ
>#include "ti83asm.inc"
>#include "tokens.inc"
>.LIST
>#DEFINE shipy 8265h
>#DEFINE shipx 8266h
>KClear .equ 191
>
>.org 9327h ; Begin
>
> call _grbufclr ; clear graph buffer
> ld hl,256*0+1
> ld (pencol),hl
> ld hl,nameandversion
> set 7,(iy+20) ; text writes to graph buffer
> call _vputs
> res 7,(iy+20) ; turn it off again
>
> ld b,12 ; draw 12 bytes = 1 row
> ld hl,8E29h+(56*12) ; address in graph buffer at row 56
>drawLineLoop:
> ld (hl),$FF ; fill byte with %11111111
> inc hl ; next byte
> djnz drawLineLoop ; repeat 12 times
>
>; ld b,0
>; ld c,56
>; ld d,94
>; ld e,56
>; ld h,1
>; call _Iline
>
> ld hl,0*256+20 ; init shipx and shipy
> ld (shipy),hl
>
>; ld a,0
>; ld (shipx),a
>; ld a,20
>; ld (shipy),a
>
>clearloop:
> ld a,0ffh
> out (1),a
> ld a, 0fdh
> out (1),a
> in a,(1)
> cp KClear
> jp z, startgame
>flyship:
> call drawship ; draw ship in graph buf
> call fastCopy ; display screen
> call drawship ; remove ship in graph buf
> ld a,(shipx)
> inc a
> ld (shipx),a
> jr clearloop
>drawship:
> ld hl,(shipy) ; hl = ship coordinates
> ld bc,4*256+2 ; bc = size of sprite
> ld ix,ship ; Load sprite name to ix
> call vnDrawPicture
> ret
>startgame:
> ret
>ship:
> .db %01000000,%01000000
> .db %00111011,%00111011
> .db %01000100,%01000100
> .db %01111111,%01111111
>
>vnDrawPicture:
> ld a,h
> ld h,0
> ld d,h
> ld e,l
> add hl,de
> add hl,de
> add hl,hl
> add hl,hl
> ld e,a
> srl e
> srl e
> srl e
> add hl,de
> ld de,8E29h
> add hl,de
> and 7
> ld e,a
>vnDrawPictureLoop1:
> push bc
> push hl
> ld b,c
>vnDrawPictureLoop2:
> ld c,(ix)
> ld d,0
> inc ix
> ld a,e
> or a
> jr z,vnDrawPicture1
>vnDrawPictureLoop3:
> srl c
> rr d
> dec a
> jr nz,vnDrawPictureLoop3
>vnDrawPicture1:
> ld a,c
> xor (hl)
> ld (hl),a
> inc hl
> ld a,d
> xor (hl)
> ld (hl),a
> djnz vnDrawPictureLoop2
> pop hl
> ld c,12
> add hl,bc
> pop bc
> djnz vnDrawPictureLoop1
> ret
>
>fastCopy:
> di
> ld a,$80
> out ($10),a
> ld hl,8E29h-12-(-(12*64)+1)
> ld a,$20
> ld c,a
> inc hl
> dec hl
>fastCopyAgain:
> ld b,64
> inc c
> ld de,-(12*64)+1
> out ($10),a
> add hl,de
> ld de,10
>fastCopyLoop:
> add hl,de
> inc hl
> inc hl
> inc de
> ld a,(hl)
> out ($11),a
> dec de
> djnz fastCopyLoop
> ld a,c
> cp $2B+1
> jr nz,fastCopyAgain
> ret
>
>nameandversion:
> .db "Ultimate Bomber v 0.11",0
>.end
>
> > ----------------------------------------
> > From: Maarten Z. <m021085@hotmail.com>
> >
> > Does anybody has a routine to display 16x16 sprites, especially a XOR
> > routine. Movax's routine is only for 8x8. Or do I have to program it for
>ION
> > using, ION putbigsprite.
> > I have also a problem with text. When I display text on the screen and
>after
> > that I put a moving 8x8 sprite on the screen, the text dissapears.
> > Also when I displayed an 8x8 moving sprite, using Movax routine, the
> > movement was terribly slow, I could do it faster in basic, I used this
> > code(don't look at the crappy sprite:
> > ..NOLIST ;Necessary stuff,
> > #define end .end
> > #define END .end
> > #define equ .equ
> > #define EQU .equ
> > #include "ti83asm.inc"
> > #include "tokens.inc"
> > ..LIST
> > #DEFINE shipx 8265h
> > #DEFINE shipy 8266h
> >
> > KClear .equ 191
> > ..org 9327h ; Begin
> > progstart:
> > call _clrLCDFull
> > ld hl,256*0+1 ; in the routine
> > ld (pencol),hl
> > ld hl,nameandversion
> > call _vputs
> > ld b,0
> > ld c,56
> > ld d,94
> > ld e,56
> > ld h,1
> > call _Iline
> > ld a,0
> > ld (shipx),a
> > ld a,20
> > ld (shipy),a
> > clearloop:
> > ld a,0ffh
> > out (1),a
> > ld a, 0fdh
> > out (1),a
> > in a,(1)
> > cp KClear
> > jp z, startgame
> > flyship:
> > call drawship
> > ld a,(shipx)
> > inc a
> > ld (shipx),a
> > call drawship
> > jr clearloop
> > drawship:
> > ld a,(shipy)
> > ld e,a
> > ld a,(shipx)
> > ld bc,ship ;Load sprite name to bc
> > call SPRXOR ;Call movax' Sprite Routine
> > call _grbufcpy_v
> > ret
> >
> >
> > startgame:
> > ret
> > ship:
> > .db %0000000000000000
> > .db %0000000000000000
> > .db %0100000001000000
> > .db %0011101100111011
> > .db %0100010001000100
> > .db %0111111101111111
> > .db %0000000000000000
> > .db %0000000000000000
> > SPRXOR:
> >
> > push bc ; Save sprite address
> >
> > ;==== Calculate the address in graphbuf ====
> >
> > ld hl,0 ; Do y*12
> > ld d,0
> > add hl,de
> > add hl,de
> > add hl,de
> >
> > add hl,hl
> > add hl,hl
> >
> > ld d,0 ; Do x/8
> > ld e,a
> > srl e
> > srl e
> > srl e
> > add hl,de
> >
> > ld de,8e29h
> > add hl,de ; Add address to graphbuf
> >
> > ld b,00000111b ; Get the remainder of x/8
> > and b
> > cp 0 ; Is this sprite aligned to 8*n,y?
> > jp z,ALIGN
> >
> >
> > ;==== Non aligned sprite blit starts here ====
> >
> > pop ix ; ix->sprite
> > ld d,a ; d=how many bits to shift each line
> >
> > ld e,8 ; Line loop
> > LILOP: ld b,(ix+0) ; Get sprite data
> >
> > ld c,0 ; Shift loop
> > push de
> > SHLOP: srl b
> > rr c
> > dec d
> > jp nz,SHLOP
> > pop de
> >
> > ld a,b ; Write line to graphbuf
> > xor (hl)
> > ld (hl),a
> >
> > inc hl
> > ld a,c
> > xor (hl)
> > ld (hl),a
> >
> > ld bc,11 ; Calculate next line address
> > add hl,bc
> > inc ix ; Inc spritepointer
> >
> > dec e
> > jp nz,LILOP ; Next line
> >
> > jp DONE1
> >
> >
> > ;==== Aligned sprite blit starts here ====
> >
> > ALIGN: ; Blit an aligned sprite to graphbuf
> > pop de ; de->sprite
> >
> > ld b,8
> > ALOP1: ld a,(de)
> > xor (hl)
> > ld (hl),a
> > inc de
> > push bc
> > ld bc,12
> > add hl,bc
> > pop bc
> > djnz ALOP1
> >
> > DONE1:
> > ret
> >
> > nameandversion:
> > .db "Ultimate Bomber v 0.11",0
> >
> > ..end
> > END
> >
> > ------------------------------------------------
> > "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.
> >
> >
> >
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at
>http://explorer.msn.com/intl.asp
> >
> >
> >
>
>-----------------------------------------------------
>Mail.be, Free WebMail and Virtual Office
>http://www.mail.be
>
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp