i understand that if i wanted to make a sprite i would have to use code that looked like this.


Code:

pic:
 .db%00011101

and so on and so forth. but if i wanted to move it around and display it what exactly would i do because 28 days got me confused and asmguru didnt even explain it.
Well, first you need to understand the basic components you need:

1>> a sprite to move around
2>> a routine to draw it at x,y
3>> a routine to erase it at x,y
4>> a routine to check keys
5>> a routine to inc/dec x and y based on keys.

Luckily, as I'm sure you know, parts (2) and (3) can use the same XORed sprite routine, such as the one Ion provides.
how exactly would i go about doing parts (2) and (3). and the xor,and,or

those things confused me a lot so i think that might be a part of my problem. as for the other parts i basicaly know how to do them.
OK, let's discuss bitwise AND, OR, and XOR then. For all these examples, let's assume we have two variables, a and b.

a = %11010010
b = %10111011

a AND b
When you bitwise AND two sets of bits together, only the bits where both are 1 become one. If one or more bits are 0, it's zero. So,

a AND b = %11010010 AND %10111011 = %10010010

a OR b
When you bitwise OR two sets of bits together, any bit where either bit is 1 become one. It's only zero when both are zero. So,

a OR b = %11010010 OR %10111011 = %11111011

a XOR b
XOR is the strangest operator of the bunch. With XOR, the output bit is only 1 if exactly one of the input bits is one and the other is zero. If both are zero, or both are one, the output is zero. Therefore:

a XOR b = %11010010 XOR %10111011 = %01101001
so with knowledge of the and,or, xor

how exactly would i do parts (2),(3),(5)

i know with five i would have to do something like


Code:


 inc (loc_x)


so the parts two and three are the only other problems
OK. When you XOR something to the screen, it draws it. But if you XOR the exact same sprite OVER that sprite, it erases it! So just XOR before the key loop to draw, then loop until you get a key, then XOR again to erase, then change the coordinates, and start over!
okay sounds easy enough. if i wanted to xor the sprite what would i do though. would this work.


Code:

 xor
 pic
pic:
 .db %001001001


also if i wanted the sprite to be larger wouldnt i have to use .dw
Come on, this is not BASIC. I'm not going to list out the routine you need to make this work, but I will tell you what it will involve and rely on you to make the code because you seem to take the easy/short way out on everything (I say this because the routine and an explanation thereof is in asmin28days and you must have just skimmed over it and expected us to explain it).

You need to basically copy the data from where the sprite is located to the graph buffer (called PlotsScreen). You can Xor it with what is there already, OR it with what is there already or do whatever other boolean logic to it, but fundamentally, all you are doing is copying the data to the PlotsScreen (which is a 768byte section of memory, each bit representing a pixel (1 on 0 off)). Now, the bit shifting and finding of where to store this sprite to in PlotsScreen I will leave up to you to figure out. I'm not about to lay out the entire routine when you are fully capable of creating it yourself.

If you do have specific questions about a certain part of the routine and have given a valid attempt yourself (not just writing xor), then we will be more than happy to help.
Maybe some code will help him out. This is a little program I made when I was first learning Asm. It's a mirage program and uses Ion libs for sprites. Note that it is for the 83+, so you'll have to change some things for the 83.

Code:

#include "ti83plus.inc"
#include   "mirage.inc"
   .org   $9D93            ;Origin (set back two to account for AsmPrgm)
   .db   $BB,$6D            ;Compiled AsmPrgm token
   ret               ;So TIOS wont run the program
   .db   1            ;Identifier as MirageOS program
   .db   %11111111,%11111111      ;15x15 button
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11111111,%11111110
   .db   %11111111,%11111100
   .db   %11000000,%00000110
   .db   %11000000,%00000111
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   %11000000,%00000011
   .db   "See Something Bounce!",0
ProgStart:
   ;isprite      - ion putsprite routine   sprites will be 8x8, so maxes will be 48 and 84
   ;input:   b=sprite height
      ;a=x coordinate
      ;l=y coordinate
      ;ix->sprite
   ;Output:   Sprite is XORed to the graph buffer.
      ;ix->next sprite
   ;Destroys: af bc de hl ix
   ;irandom      - ion random routine
   ;Input:   b=upper bound
   ;Output: a=answer (0<=a<b)
      ;b=0
   ;Destroys af b
   ;ifastcopy   - ion fastcopy routine
   ;Input:   nothing
   ;Output:   graph buffer is copied to the screen
   ;Destroys: af bc de hl
   ;fastcopys   - Runs fastcopy, but preserves all registers
   ;row  change all occurences of xcoor, etc to address   xcoor1 is $8000 ycoor1 is $8002 addx1 is $8004 addy1 is $8005
   ;xcoor2 is $8006 xcoor3 is $8008 xcoor4 is $800A ycoor2 is $800C ycoor3 is $800E ycoor4 is $8010 addx2 is $8012 addx3 is $8013
   ;addx4 is $8014 addy2 is $8015 addy3 is $8016 addy4 is $8017
   bcall(_ClrLCDFull)
   bcall(_RunIndicOff)
   ld b,86
   call irandom
   ld ix, $8000
   ld (ix),a
   ld b,86
   call irandom
   ld ( ix + $6),a
   ld b,86
   call irandom
   ld (ix + $8),a
   ld b,86
   call irandom
   ld (ix + $A),a
   ld b,56
   call irandom
   ld (ix + $C),a
   ld b,56
   call irandom
   ld (ix + $E),a
   ld b,56
   call irandom
   ld (ix + $10),a
   ld b,56
   call irandom
   ld (ix + $2),a
   ld a,1
   ld (ix + $4),a      ;61
   ld (ix + $5),a
   ld (ix + $12),a
   ld (ix + $16),a
   neg
   ld (ix + $13),a
   ld (ix + $14),a
   ld (ix + $15),a
   ld (ix + $17),a
Draw:
   bcall(_GrBufClr)
   ld b,8
   ld ix, $8000
   ld a,(ix)
   ld l,(ix +  $2)
   ld ix,Ball      ;ball will be sprite
   call isprite
   ld ix, $8000
   ld b,8
   ld a,(ix + $6)
   ld l,(ix + $C)
   ld ix,Ghost
   call isprite
   ld ix, $8000
   ld b,8
   ld a,(ix + $8)
   ld l,(ix + $E)
   ld ix,Man
   call isprite
   ld ix, $8000
   ld b,8
   ld a,(ix + $A)
   ld l,(ix + $10)
   ld ix,Superman
   call isprite
   call ifastcopy
   bcall(_GetCSC)
   cp skEnter
   jp z,Quit
   ld b,5
   call delayb
Check:
   ld ix, $8000
   ld a,(ix + $2)
   cp 1
   jp c,Incol1
   cp 56
   jp nc,Decol1
   ld a,(ix)
   cp 1
   jp c,Incrow1
   cp 86
   jp nc,Decrow1
   ld a,(ix + $6)
   cp 1
   jp c,Incrow2
   cp 86
   jp nc,Decrow2
   ld a,(ix + $C)
   cp 1
   jp c,Incol2
   cp 56
   jp nc,Decol2
   ld a,(ix + $8)
   cp 1
   jp c,Incrow3
   cp 86
   jp nc,Decrow3
   ld a,(ix + $E)
   cp 1
   jp c,Incol3
   cp 56
   jp nc,Decol3
   ld a,(ix + $A)
   cp 1
   jp c,Incrow4
   cp 86
   jp nc,Decrow4
   ld a,(ix + $10)
   cp 1
   jp c,Incol4
   cp 56
   jp nc,Decol4
   jp Update
Incol1:   ;ld a,1
   ld b,1
   ld (ix +  $5),b
   ld a,(ix + $2)
   add a,b
   ld (ix + $2),a
   jp Check
Decol1:   ;ld a,blah
   ld b,%11111111
   ld (ix + $5),b
   ld a,(ix + $2)
   add a,b
   ld (ix + $2),a
   jp Check
Incrow1:   ;ld a,blah
   ld b,1
   ld (ix + $4),b
   ld a,(ix)
   add a,b
   ld (ix),a
   jp Check
Decrow1:   ;ld a,blah and point 100
   ld b,%11111111
   ld (ix + $4),b
   ld a,(ix)
   add a,b
   ld (ix),a
   jp Check
Incrow2:
   ld b,1
   ld (ix + $12),b
   ld a,(ix + $6)
   add a,b
   ld (ix + $6),a
   jp Check
Decrow2:
   ld b,%11111111
   ld (ix + $12),b
   ld a,(ix + $6)
   add a,b
   ld (ix + $6),a
   jp Check
Incol2:
   ld b,1
   ld (ix + $15),b
   ld a,(ix + $C)
   add a,b
   ld (ix + $C),a
   jp Check
Decol2:
   ld b,%11111111
   ld (ix + $15),b
   ld a,(ix + $C)
   add a,b
   ld (ix + $C),a
   jp Check
Incrow3:
   ld b,1
   ld (ix + $13),b
   ld a,(ix + $8)
   add a,b
   ld (ix + $8),a
   jp Check
Decrow3:
   ld b,%11111111
   ld (ix + $13),b
   ld a,(ix + $8)
   add a,b
   ld (ix + $8),a
   jp Check
Incol3:
   ld b,1
   ld (ix + $16),b
   ld a,(ix + $E)
   add a,b
   ld (ix + $E),a
   jp Check
Decol3:
   ld b,%11111111
   ld (ix + $16),b
   ld a,(ix + $E)
   add a,b
   ld (ix + $E),a
   jp Check
Incrow4:
   ld b,1
   ld (ix + $14),b
   ld a,(ix + $A)
   add a,b
   ld (ix + $A),a
   jp Check
Decrow4:
   ld b,%11111111
   ld (ix + $14),b
   ld a,(ix + $A)
   add a,b
   ld (ix + $A),a
   jp Check
Incol4:
   ld b,1
   ld (ix + $17),b
   ld a,(ix + $10)
   add a,b
   ld (ix + $10),a
   jp Check      ;line 280
Decol4:
   ld b,%11111111
   ld (ix + $17),b
   ld a,(ix + $10)
   add a,b
   ld (ix + $10),a
   jp Check
Update:
   ld a,(ix)
   ld h,(ix + $4)
   add a,h
   ld (ix),a
   ld a,(ix + $2)
   ld h,(ix + $5)
   add a,h
   ld (ix + $2),a
   ld a,(ix + $6)
   ld h,(ix + $12)
   add a,h
   ld (ix + $6),a
   ld a,(ix + $8)
   ld h,(ix + $13)
   add a,h
   ld (ix + $8),a
   ld a,(ix + $A)
   ld h,(ix + $14)
   add a,h
   ld (ix + $A),a
   ld a,(ix + $C)
   ld h,(ix + $15)
   add a,h
   ld (ix + $C),a
   ld a,(ix + $E)
   ld h,(ix + $16)
   add a,h
   ld (ix + $E),a
   ld a,(ix + $10)
   ld h,(ix + $17)
   add a,h
   ld (ix + $10),a
   jp Draw
Ghost:
   .db %00111100
   .db %01111110
   .db %01101010
   .db %01111110
   .db %01111110
   .db %01111110
   .db %11111111
   .db %10110101
Ball:
   .db %00000000
   .db %00111100
   .db %01100110
   .db %01100110
   .db %01111110
   .db %01111110
   .db %00111100
   .db %00000000
Man:
   .db %10110000
   .db %10110000
   .db %10010000
   .db %01111111
   .db %00110111
   .db %00110111
   .db %00110010
   .db %11001100
Superman:
   .db %00111100
   .db %01000010
   .db %11011111
   .db %11000011
   .db %11111011
   .db %01000010
   .db %00111100
   .db %00011000
Quit:
   bcall(_GetKey)
   bcall(_ClrLCDFull)
   bcall(_RunIndicOn)
   ret
end
end

On a side note, did the tag buttons always look like that? They look cool.
No, I reskinned a few of the forum features recently. Smile
I think that that could be simplified a ton. I'd post up the Doors CS mouse routine, but that would just confuse you more due to all the dynamic cursor stuff.
okay i guess i will just go through and try to create it myself. hopefully i can do it. the only thing i need to know is how exactly do i use the xor command like do i:


Code:

xor
pic


or:


Code:

xor pic
No no no. You can't just xor all at once. You can only xor one byte with another byte at a time in z80 asm. To do this, use ionPutSprite, which XORs a sprite with the graphbuffer. It does all the alignment and everything so you only need to worry about keeping the coordinates up to date.
Like I said before there's A TON MORE TO IT THAN THAT!!! But, since you insist, xor's syntax is as follows:


Code:
  xor n
where n is a number between 0 and 255 or an eight bit register. It will xor the contents of n with the accumulator. It can also be used for a quicker/smaller way to ld a,0 by doing xor a.
where exactly can i find ionputsprite. and will it be an ion program if i use ionputsprite.
If you want to include it yourself, get the Ion source code at ticalc.org. If you're programming for Ion, DCS, or a similar shell, you can just do
Code:
call iPutSprite
or
Code:
call ionPutSprite
depending on the shell, as long as you have the correct include file in the header.
You would have to use Ion to be able to use the library within Ion. Personally, I think you should be able to make the display routine yourself before you use ion's library. Depending on libraries to do all the hard and messy stuff for you sounds a little bit like BASIC? Wink

Edit: Kerm keeps beating me with the replies. He's a machine. Very Happy
i guess i will forget the libs for now since i am not that experienced. and i guess i will just experiment until i get it right.

<off topic>Do games go faster in ion or any other shell?
Re: libs: fair enough
Re: speed: all assembly programs, shell or not, run at the same speed with a few minor exceptions for the 83+SE and 84+SE.
Re: Chip: ha! pwned. Smile
allright now i know this might make you guys frustrated or mad Mad . but i know how to create the sprite but putting it on the screen is super confusing and i went and read over asm lesson a couple more times and i am still confused. and chipmaster i am not asking for the code for it i am just asking how in the world would i do it.
Go to ticalc.org and look in the ASM source directory. There are some beginner, easy programs w/ source there to show you basic things like what you are asking
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page 1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 1 of 6
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement