Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Ashbad on December 14, 2010, 03:54:33 pm
-
I just finished a 4 level 8x8 sprite drawing routine, but it does not seem to be working.... the drawing to buffers (appbackupscreen is backbuffer, plotSScreen is front buffer) works, but the coordinate system and address don't work (HL: address to data, b = x position*8, c = y position)
Help?
ALSO, I do know this is rather newbish, but I never really was good at sprite routines :P
Drawalignedsprite
push hl
ld a,c
add a,a
add a,c
add a,a
add a,a
ld l,c
push af
ld a,l
add a,b
ld l,a
pop af
ld h,0
ld de,appbackupscreen
add hl,de
push de
ld de,plotSScreen
add de,hl
sub a
ld b,8
ld c,16
pop hl
__Drawalignedspriteloop
ld a,(hl)
ex de,hl
ld (hl),a
inc de
add hl,12
ex de,hl
dec c
sub a
cp c
jp z,__Drawalignedspriteend
add 8
cp c
jp z,__Drawalignedspriteloopnext
djnz __Drawalignedspriteloop
__Drawalignedspriteloopnext
ld b,8
pop de
sub a
cp c
jp nz,__Drawalignedspriteloop
__Drawalignedspriteend
ret
EDIT: fixed some bad syntax stuff (this is my incomplete version, left my finished one at school with syntax fixed) BUT the routine is still dysfunctional :P
-
well.. i'm not sure what's wrong with your code but this is what i could come up with. though i wasn't sure what you meant by b being x position * 8. is x position the number of bytes to the right? that's what i assumed, at least. in which case i assumed x position is a variable i could access. also, this routine xors the sprite.
i'm not 100% sure this routine works, since i haven't taken quigibo's grayscale routine and used it, but it's what i could come up with. it's found here (http://pastebin.com/8sY4RbPE). let me know if it works, if it fails. i haven't programmed in asm in awhile, but this is the routine i made for a little tunnel game i was trying to make. except i modified it to write to appbackupscreen too.
-
thanks for the help, but I was able to rewrite the routine (that now works) :)
Thanks, though ;)
Maybe I can butcher this thread into a Trio and niko: falling Help-me-plz-thread and I can keep changing the title to get new input on new questions O.o
ALSO: how optimal is my clrbuffers routine?
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
inc hl
ex de,hl
ld (hl),a
inc hl
ex de,hl
dec bc
cp b
jp z,__Clrscrnloop
cp c
jp z,__Clrscrnloop
__Clrscrnend
ret
EDIT: I just realized I can do ld (de),a :P there goes two lines of code:
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
inc hl
ld (de),a
inc de
dec bc
cp b
jp z,__Clrscrnloop
cp c
jp z,__Clrscrnloop
__Clrscrnend
ret
-
Yay for special-purpose instructions :)
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
ldi
jp pe,__Clrscrnloop
ret
-
O.o what does the pe flag do? also, I've seen the po flag used before (ahem quigibo's grayscale routine) can you explain to me the fthe different flags (sorry for wasting your time :()
And, cool usage of the ldi instruction, I usually never use it much O.o
-
O.o what does the pe flag do? also, I've seen the po flag used before (ahem quigibo's grayscale routine) can you explain to me the fthe different flags (sorry for wasting your time :()
And, cool usage of the ldi instruction, I usually never use it much O.o
In the case of the ldi/ldd/cpi/cpd instructions, the parity/overflow flag is set to 1 (PE) if BC is non-zero, or 0 (PO) if BC is zero. In this case, we want to loop if BC is not zero.
-
In the context of ldi, the p/o flag is set (pe) if bc is not zero, and reset (po) if it is. (ldi decrements bc)
Edit: ninja'd
-
ooh, cool! thanks for the helpful insight! :D
that really would save a ton of space if I use that more often O.o
-
One thing to keep in mind is that with JR, only the NZ/Z/NC/C conditions are available. For the PO/PE/P/M conditions, JP must be used.
-
quick question, for each of may pages, if I want to include some of my routines in let's say, TaNrout.inc, can I put an include on every page, so I won't have to flip pages and lose speed, or copy and paste them and create a mess of code? like in brass:
.page 0
#include TaNrout.inc
.page 1
#include TaNrout.inc
.page 2
#include TaNrout.inc
Like that to put the code in the includes into the current location?
-
*bump* ^^^
-
You can. Unless you absolutely need that speed or have the space, though, you might just want to put it on one page.
Also, I'm not sure if you know this or not, so here's a quick tutorial on how to create and format apps: http://benryves.com/bin/brass/tutorials/tiapps.htm (http://benryves.com/bin/brass/tutorials/tiapps.htm)
-
Does anybody know of a good gray scale rendering routine, like Dispgraphrr in Axe (and besides the source for that, it doesn't work on it's own)
it would really help me a ton.
-
bump
-
That was a very well-deserved bump. Have you checked Doors CS SDK?
-
it doesn't have anything like that, and since it's an app I can't use anything to do with a shell like DCS7
-
it doesn't have anything like that, and since it's an app I can't use anything to do with a shell like DCS7
Yes, I really can't get why nobody helps you with this :S
-
Does anybody know of a good gray scale rendering routine, like Dispgraphrr in Axe (and besides the source for that, it doesn't work on it's own)
it would really help me a ton.
Wait, why wouldn't that routine work on its own?
-
It seems that on wabbit it doesn't display sprites in the right positions (even with a sprite routine from ion) and on mimas, it shows garbage
-
Well, you can't just use a normal sprite routine for grayscale. You have to draw a sprite to each buffer (and did you clear both buffers first?)
-
yeah, I cleared both buffers, and I modified the ion one to output the same stuff to both buffers.
EDIT: it gets the byte at flags+asm_flag2 near the beginning; I wonder if a command uses that earlier to set something?
Disp4
ld a,i
push af
di
ld (OP2+2),sp
ld a,$80
out ($10),a
ld sp,appbackupscreen - plotSScreen
ld e,(plotSScreen-appbackupscreen+12)&$ff
ld c,-$0C
ex af,af'
ld a,%11011011
ld hl,flags+asm_flag2
inc (hl)
jr z,__Disp4Lvlskip
add a,a
ld b,(hl)
inc b
jr z,__Disp4Lvlskip
rlca
ld (hl),-2
__Disp4Lvlskip
ld l,plotSScreen&$ff-1
ex af,af'
__Disp4Lvlentry
ld a,c
add a,$2C
ld h,plotSScreen>>8
inc l
ld b,64
out ($10),a
__Disp4Lvlloop
ld a,(hl)
add hl,sp
xor (hl)
ex af,af'
cp e
rra
ld d,a
ex af,af'
and d
xor (hl)
out ($11),a
ld d,(plotSScreen-appbackupscreen+12)>>8
add hl,de
djnz __Disp4Lvlloop
inc c
jr nz,__Disp4Lvlentry
__Disp4LvlDone
ld sp,(OP2+2)
pop af
ret po
ei
ret
__Disp4LvlEnd
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
ldi
jp pe,__Clrscrnloop
ret
Drawtilebuffer
ld e,l
ld h,$00
ld d,h
add hl,de
add hl,de
add hl,hl
add hl,hl ;Find the Y displacement offset
ld e,a
and $07 ;Find the bit number
ld c,a
srl e
srl e
srl e
add hl,de ;Find the X displacement offset
ld de,plotSScreen
add hl,de
putSpriteLoop1:
sl1: ld d,(ix) ;loads image byte into D
ld e,$00
ld a,c
or a
jr z,putSpriteSkip1
putSpriteLoop2:
srl d ;rotate to give out smooth moving
rr e
dec a
jr nz,putSpriteLoop2
putSpriteSkip1:
ld a,(hl)
xor d
ld (hl),a
inc hl
ld a,(hl)
xor e
ld (hl),a ;copy to buffer using XOR logic
ld de,$0B
add hl,de
inc ix ;Set for next byte of image
djnz putSpriteLoop1
ret
Drawtilebackbuffer
ld e,l
ld h,$00
ld d,h
add hl,de
add hl,de
add hl,hl
add hl,hl ;Find the Y displacement offset
ld e,a
and $07 ;Find the bit number
ld c,a
srl e
srl e
srl e
add hl,de ;Find the X displacement offset
ld de,appbackupscreen
add hl,de
putSpriteLoop1:
sl1: ld d,(ix) ;loads image byte into D
ld e,$00
ld a,c
or a
jr z,putSpriteSkip1
putSpriteLoop2:
srl d ;rotate to give out smooth moving
rr e
dec a
jr nz,putSpriteLoop2
putSpriteSkip1:
ld a,(hl)
xor d
ld (hl),a
inc hl
ld a,(hl)
xor e
ld (hl),a ;copy to buffer using XOR logic
ld de,$0B
add hl,de
inc ix ;Set for next byte of image
djnz putSpriteLoop1
ret
Tilemap