[TI ASM] Non-aligned Sprite Displaying Algorithm

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

[TI ASM] Non-aligned Sprite Displaying Algorithm

Post by cjgone »

Can someone analyze my sprite displaying routine. I'm sorry that I did not add really useful comments :\ It uses the exact pixel on the screen, not the x and y coordinates. I have yet to do that :l Accepting suggestions :)

.NOLIST
#define EQU .equ
#define equ .equ
#define END .end
#define end .end
#include "ti83plus.inc"
.LIST

.org 9D93h
.db $BB,$6D
; Sprite Displaying Routine
______ ld hl,(Pixel) ;------ exact pixel to display to
______ ld a,l
______and %00000111 ;----- find the remainder of hl \ 8
______ ld b,a ;----- load the reaminder into b
______ld a,(Sprite)
______ld h,a ;----- load the image that is to be displayed into h
______ ld a,(Sprite_2)
______ ld l,a ;----load the image that is to be displayed into l
______ ld a,1 ; use a as a counter
Loop:
______ srl h ; this is the bit offset
______ rr l
______ or a
______ cp b
______ jp z,Next
______ inc a
______ jp Loop
Next:
______ ld a,h
______ ld (Spr),a ; -------store the fixed h and l registers into memory
______ ld a,l
______ ld (Spr_2),a
______ ld hl,$9340 ; ------ld hl with the screen buffer equate of Plotsscreen
______ ld de,(Pixel)
______ srl d
______ rr e
______ or a ;---------- reset the carry flag
______ srl d ; --------divide the pixel by 8
______ rr e
______ or a
______ srl d
______ rr e
______ or a
______ add hl,de
______ ld a,(Spr) ;--------- retrieve the stored memory
______ ld (hl),a
______ inc hl
______ ld a,(Spr_2)
______ ld (hl),a
______ B_CALL(_Grbufcpy)
______ ret


Sprite:
______ .db %11111111
Sprite_2:
______.db %00000000
Spr:
______ .db %00000000
Spr_2:
______.db %00000000
Pixel:
______ .db 734 ;----- pixel

.end
end
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Re: Non-aligned Sprite Displaying Algorithm

Post by Liazon »

at least i can still edit :D

so no one can see how stupidly i forgot the difference between preprocessor absolute addressing, and variable program addressing :(
Last edited by Liazon on Wed 31 May, 2006 1:45 am, edited 1 time in total.
Image Image Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

I was wondering if you had tested that yet? There ar e a few errors that i can see, and the method is unknown to me. Unfortunately i dont have much time to test it for you right now.

A good idea would be to grab the ion source and study the 'ionPutSprite' routine.

There is also a tutorial on an unaligned sprite routine in the ASM in 28 Days guide, which can be found on ticalc.org.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

Hmmm, it did work. The only thing that I'm not sure about is ---ld hl,(Pixel)... I added that so it was not showing one value as (Pixel), is what the pixel is. I don't know why I made two sprite labels. Its a bit dumb, sorry. This is no stub asm.
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

I'm pretty sure this routine should be common, since the addresses for the screen are 8-bit, which each contain 8-pixels. If you were using an exact pixel, you would need to divide that pixel by 8 to get the adress its on. The remainder of the division should be the bit offset of the sprite....
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

That is true, you perform a % 8 to find the pixel offset for the byte and you divide by 8 to find that byte: PlotsScreen+((y*12)+(x/8)).

An 8x8 unaligned sprite routine is pretty common, just not using the same methodology you do. You should check out the ion source to find a more standard way to do it.
Last edited by tr1p1ea on Sat 27 May, 2006 12:46 am, edited 1 time in total.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

You should shift the byte to the right Xvalue%8 times, write it to the correct X/8 and Y byte in the buffer, then get whatever was shifted off and write it to the next bit over. I can't code it out for you now, but a good idea would be to look at something like Movax's, Sigma's (asm in 28 days), or ion's sprite routines. They all (especially the 28 days one) explain and show how to do it.
Image
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

:\ Are you saying that my routine is very inefficient?
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

Hmm, I'm going to go work on a more effiecient x and y coordinate displaying routine..
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Read the guides, that's what they are there for.
Image
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

And no double posting.
Image Image Image
Post Reply