Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Hot_Dog on October 21, 2010, 03:46:26 pm
-
How do I go about drawing a sprite so that 1s are black and 0s are white? All I need is the basics behind it, no code or anything.
I tried writing my own routine, but as I draw byte by byte, there's either some transparency, or the next byte of pixel data messes up what's in the previous byte of pixel data. I'm trying to duplicate "B_CALL DisplayImage." Oh, and by the way, I don't care if there's a "white square" appearing around the sprite like Ti's DisplayImage. In fact, I'm trying to achieve the same effect with no results.
-
Can you give a pic of what it is doing, and what you want it to do?
From what I'm reading, I think you just clear the background first, unless I don't understand your post correctly.
-
Hm... I can give a general ASM tip to help with the messed up pixels problem. (Unless I have misunderstood, of course. Credit for this method, AFAIK, goes to calc84maniac)
xor b
and c
xor b
It effectively selects bits from b to put in a.
A set bit in c corresponds to leaving the original corresponding bit in a, and a reset bit corresponds to overwriting that bit in a with b.
For example, if a=%10100110, b=%01101011, and c=%11001101, then the result would be %10100110 in a, with bits 0, 2, 3, 6, and 7 coming from a and bits 1, 4, and 5 coming from b.
-
So, say this is my sprite routine, which causes messed up pixels:
Put_Sprite_Overwrite:
; A = x coordinate
; L = y coordinate
; B = number of rows
;
; IX = address of sprite
LD H, 0
LD D, H
LD E, L
ADD HL, HL
ADD HL, DE
ADD HL, HL
ADD HL, HL
LD E, A
SRL E
SRL E
SRL E
ADD HL, DE
LD DE, plotsscreen
ADD HL, DE
AND 7
JR Z, _AlignedOverwrite
LD C, A
PUSH HL
LD A, 12
LD HL, Sprite_Width
SUB (HL)
LD D,0
LD E, A
POP HL
_RowLoopOverwrite:
PUSH BC
;Stores width into B, which will be decreased 1 by 1 until one row is complete
LD A, (Sprite_Width)
LD B, A
_ColumnLoopOverwrite:
PUSH BC
LD B, C
LD C, (IX)
XOR A
_ShiftLoopOverwrite:
SRL C
RRA
DJNZ _ShiftLoopOverwrite
INC HL
LD (HL), A
DEC HL
LD A, C
LD (HL), A
POP BC
INC HL
INC IX
DJNZ _ColumnLoopOverwrite
ADD HL, DE
POP BC
DJNZ _RowLoopOverwrite
RET
_AlignedOverwrite:
PUSH HL
LD A, 12
LD HL, Sprite_Width
SUB (HL)
LD D,0
LD E, A
POP HL
_PutLoopOverwrite:
PUSH BC
LD A, (Sprite_Width)
LD B, A
_PutLoopOverwrite2:
LD A, (IX)
LD (HL), A
INC IX
INC HL
DJNZ _PutLoopOverwrite2
_PutLoopOverwriteAdd:
POP BC
;ADD HL, DE
;DJNZ _PutLoop
ADD HL, DE
DJNZ _PutLoopOverwrite
RET
What do I plug in for "xor b, and c, xor b"?
-
This should just work with overwrite routine, shouldn't it?