Re: A86: Re: moving a sprite


[Prev][Next][Index][Thread]

Re: A86: Re: moving a sprite




Your problem is probably that your sprite coords are getting trashed.
Since you are trying to keep them in registers, you might try adding pushes
and pops to preserve them when calling other routines.  DrawSprite most
likely destroys them.  Also, make sure that you are pointing to the sprite
before you call the routine.  That always helps...

You also need to start debugging your own code.  That's a huge part of
programming.  I'd say that at least 50-75% of programming time is actually
debugging, not actual coding.  It might help you to comment your code.  At
least it helps me.  When you write a routine, run it through in your head
and keep track of the registers and stuff.  If you do that, then code works
most of the time.  When you just throw stuff together, that's when you
debug for hours and hours.

Since you are programming on the emu, you really need to learn to debug
using it.  The emu is a great debugging tool (though it could be much
better).  Here is a step-by-step process on how to debug using TI86EMU:

Load your program.
Dissassemble the code starting at the label where you want to debug at.  If
you want to start at the beginning, you can use $d748 (_asm_exec_ram).  If
not, type in the value of the label (you can get this from assembly
studio's symbol table).
Double-click on that line to set a break point on it.
Run the program.
When it gets to the breakpoint, the emu will stop.  You are now at the
beginning of the troublesome code (or program).
Note:  you may have to hit dissassemble again with the same address to get
it to display correctly.
Use the step button to step-through your code.  Watch the registers and the
flow of the code as it executes.  Make sure it does exactly what you
intended it to do.  If not, then you found your error.  Fix it and start
all over.

This may seem complicated, but it's really not.  If you can't handle this,
then you probably shouldn't be programming in asm yet.  Learn a simpler
language like C or Pascal first (let's not start a debate, this is all
IMHO, but asm can be very hard if you don't know another language besides
Basic).

A big source of errors that I have spent hours on is instructions not
behaving like you would expect them to.  For example, a 16-bit load from
memory loads in opposite order of the register (i.e. LD HL,(mem) would load
(mem+1) into H and (mem) into L).  The assembly studio help file neglects
to tell you some stuff, and I think it's wrong for some things (can't
remember).  But if you're positive your code is perfect, it may be, if the
instructions were actually like you thought they were.  Another example is
the various flags that instructions set...they vary from one to the next,
especially the repeat instructions.

This sure got long...hope it helps someone.

At 10:59 PM 9/16/98 EDT, you wrote:
>
>In a message dated 9/16/98 7:54:59 PM Pacific Daylight Time,
>assets@eden.rutgers.edu writes:
>
><< Yeah, you only copied half of it.  This is just a findpixel routine that
> jumps to (bc) at the end. >>
>
>I tried it with the WHOLE thing and it still didn't work.  I included the
code
>jsut in case the original putsprite had problems unnoticible to the amatuer
>eye.


--
David Phillips
mailto:electrum@tfs.net
ICQ: 13811951
AOL/AIM: Electrum32


References: