[TI ASM] Non-aligned Sprite Displaying Algorithm
Moderator: MaxCoderz Staff
-
- Regular Member
- Posts: 83
- Joined: Tue 18 Apr, 2006 5:33 am
- Location: Washington->UC Berkeley '15
[TI ASM] Non-aligned Sprite Displaying Algorithm
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
.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
Re: Non-aligned Sprite Displaying Algorithm
at least i can still edit
so no one can see how stupidly i forgot the difference between preprocessor absolute addressing, and variable program addressing
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.
- 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:
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.
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.
- 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:
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.
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.
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
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.
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact: