Re: A86:4 Questions


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

Re: A86:4 Questions




>
>4 (possibly stupid to the advanced programmers) questions:
>
>1) what the heck is text_shadow?
>

_textShadow, or the "text shadow", is where the OS "shadow's text".  The
text you see on the homescreen is not actually stored as the pixel data, but
as text in _textShadow.  It is 168 bytes, or 8*21 (screen text resolution).
This is a good place to store temp data for your program (a carry over from
TI-85 programming).  If you don't clear it before your program ends, you
will see garbage on the homescreen:

  set appTextSave,(iy+appflags)
  call _clrScrn

>2) for this question, i shall cut and paste some code from Sqrxz:
>            XScr    = $C0F9
>            XBlock    = $C0FC
>            LevelSize    = $C0FD
>    what do these things do?  i know they're equates and all that, but are
>they kinda like the equivalent of variables?  Are $C0FC and those things
just
>spaces in the RAM, or are they ROM calls or what?
>

Jimmy Mardell likes to confuse newbies by using the actual memory locations
:)

_textShadow starts at $C0F9, so these variables are actually inside text
shadow memory.  They are like variables for your program.  These could have
been written like this, and would be more clear (like most other programs):

  XScr      = _textShadow      ; [3]  note: I write the size
  XBlock    = _textShadow + 3  ; [1]        of variables next
  LevelSize = _textShaodw + 4  ; [1]        to them

This is how you declare "variables" for use in your program.  By using
offsets instead of the memory location, you will save yourself lots of time
and headaches when programming.  Also, I think it's a good idea to note the
size (makes it easy to calculate offsets) and purpose next to variables.

>3) again taken as an example from Sqrxz: res appTextSave,(iy+appflags)
>      what does this do?  i know it resets the bit in whatever appTextSave
is,
>but what are appTextSave and iy+appflags?
>

The system uses flags to determine alot of stuff.  As demonstrated by my
earlier prot.asm program, just setting/reseting a couple of flags can have a
dramatic impact on your calc's behavior.  The IY register points to the
start of the flags.  appTextShave is the bit of the flag, and appflags is
the byte.  I don't know what the actual values are (you usually don't need
to, that's why they're equates), but pretend AppTextSave is bit 3 and
appflags is 12:

  res appTextSave,(iy+appflags)      would become

  res 3,(iy+12)

If the bit is set, then _clrScrn will clear the text shadow and the screen.
If it is set, then writting large text will also erase text shadow (which
can mess with your variables stored there).  For a complete list, see Joshua
Seagoe's page, 86 Central or the Assembly Studio 86 help file.

>4) finally, i have built this program just to try to figure out if I knew
how
>to use sprites and the PutSprite routine......obviously not because either
I'm
>not getting a key correctly, or I just have a simple mistake with my
program
>that one of you ASM wizards could show me.
>
>
>#include "ti86asm.inc"
>#include "asm86.h"
>
>.org _asm_exec_ram
>
>MainLoop45:
> call _clrLCD
> call BUSY_OFF
> ld ix,NewSprite
> ld hl,$fc00

You don't need this, because Dux's PutSprite always writes to video memory.
You'd have to change FindPixel to modify this.

> ld bc,$4028
> call PutSprite
>ASK_FOR_KEY:
> call _getky
> cp K_LEFT
> jp z,LEFT
> cp K_RIGHT
> jp z,RIGHT
> cp K_SECOND
> jp z,SECOND
> cp K_EXIT
> jp z,EXIT
> jp ASK_FOR_KEY

These could all be JR's...it will make your program smaller.

>LEFT:
> ld a,16
> cp b
> jr z,ASK_FOR_KEY
> dec b
> ld ix,NewSprite
> call PutSprite
> jr ASK_FOR_KEY
>RIGHT:
> ld a,112
> cp b
> jr z,ASK_FOR_KEY
> inc b
> ld ix,NewSprite
> call PutSprite
> jr ASK_FOR_KEY
>SECOND:
> inc c
> inc c
> inc c

What's this do?  Add 3 to your Y coord?

> ld b,35

This is going to trash your X coord, unless that's what you want it to do.

>Loop:
> push bc            ;push counter
> inc c
> ld ix,NewSprite2
> call PutSprite
> ld a,8
> cp c

Why do you have this here?  You loaded $20 into C above, so it's never going
to be less than that (since you are always incrementing it).

> jp z,ASK_FOR_KEY

This is going to kill you.  You pushed BC but didn't pop it before jumping
out of the loop, so you are trashing the stack here.

> pop bc              ;get back counter
> djnz Loop
>EXIT:
> ret
>
[snip excess code]
>
>well, i hope someone out there can find something wrong with my code.  I
would
>recommend running it in an emulator, as it will probably crash your calc.
>

If you want a simple sprite example, check out
http://www.ticalc.org/pub/86/asm/source/sprmove.asm (think that's right)





Follow-Ups: