This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Jerros


Newbie


Joined: 03 Jul 2010
Posts: 8

Posted: 06 Jul 2010 03:02:56 am    Post subject:

I've recently converted my programm into an APP, but the sprites won't display correctly.
I know you can't use any self-modifieing code in an APP, but I don't know where the problem lies.
So what's the piece thats failing because it's an APP?
And more importantly, how do I fix it?
I'm a real newby in programming, so don't be afraid to overexplain things. Rolling Eyes
The script I use is ripped directly from the asm-in-28 tutorial:


Code:

    LD      A, 28                  ; X position of sprite
    LD      (xpos), A
    LD      A, 38                  ; Y position of sprite
    LD      (ypos), A
    LD      B, 11                  ; Length in Y direction of the sprite
    LD      DE, (ypos)
    LD      IX, Sprite
    CALL   ShowSprite

Sprite:
   .db 00000001
   .db 00000010
   .db 00000100
   .db 00001000
   .db 00010000
   .db 00100000
   .db 01000000
   .db 10000000
   .db 01000000
   .db 00100000
   .db 00010000

Showsprite:                  ; Show Sprite (XOR)
        CALL    ClipSprXOR
        b_call _GrBufCpy
   ret

ClipSprXOR:                  ; Show Sprite XOR
    LD     A, %11111111
    LD     (clip_mask), A
    LD     A, E
    OR     A
    JP     M, ClipTop
    SUB    64
    RET    NC
    NEG
    CP     B
    JR     NC, VertClipDone
    LD     B, A
    JR     VertClipDone
ClipTop:
    LD     A, B
    NEG
    SUB    E
    RET    NC
    PUSH   AF
    ADD    A, B
    LD     E, 0
    LD     B, E
    LD     C, A
    ADD    IX, BC
    POP    AF
    NEG
    LD     B, A
VertClipDone:
    LD     C, 0
    LD     A, D
    CP     -7
    JR     NC, ClipLeft
    CP     96
    RET    NC
    CP     89
    JR     C, HorizClipDone
ClipRight:
    AND    7
    LD     C, A
    LD     A, %11111111
FindRightMask:
    ADD    A, A
    DEC    C
    JR     NZ, FindRightMask
    LD     (clip_mask), A
    LD     A, D
    JR     HorizClipDone
ClipLeft:
    AND    7
    LD     C, A
    LD     A, %11111111
FindLeftMask:
    ADD    A, A
    DEC    C
    JR     NZ, FindLeftMask
    CPL
    LD     (clip_mask), A
    LD     A, D
    ADD    A, 96
    LD     C, 12
HorizClipDone:
    LD     H, 0
    LD     D, H
    LD     L, E
    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
    LD     D, 0
    LD     E, C
    SBC    HL, DE
    AND    7
    JR     Z, _Aligned
    LD     C, A
    LD     DE, 11
_RowLoop:
    PUSH   BC
    LD     B, C
    LD     A, (clip_mask)
    AND    (IX)
    LD     C, 0
_ShiftLoop:
    SRL    A
    RR     C
    DJNZ   _ShiftLoop
    XOR    (HL)
    LD     (HL), A
    INC    HL
    LD     A, C
    XOR    (HL)
    LD     (HL), A
    ADD    HL, DE
    INC    IX
    POP    BC
    DJNZ   _RowLoop
    RET
_Aligned:
    LD     DE, 12
_PutLoop:
    LD     A, (IX)
    XOR    (HL)
    LD     (HL), A
    INC    IX
    ADD    HL, DE
    DJNZ   _PutLoop
    RET

clip_mask:      .DB     0



Last edited by Guest on 06 Jul 2010 10:30:21 am; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 06 Jul 2010 08:57:47 am    Post subject:

Jerros wrote:


Code:

Sprite:
    00000001
    00000010
    00000100
    00001000
    00010000
    00100000
    01000000
    10000000
    01000000
    00100000
    00010000


That's not a valid way to put data. I'm surprised your assembler isn't giving an error. It should be:

Code:

Sprite:
    .db 000001
    .db 000010
    .db 000100
    .db 001000
    .db 010000
    .db 100000
    .db %01000000
    .db %10000000
    .db %01000000
    .db 100000
    .db 010000


Assuming that's not the problem, where is the location of "clip_mask"?

Edit:
Meh, the forum ate my "% 00". Just pretend they are still there >_>


Last edited by Guest on 06 Jul 2010 08:59:18 am; edited 1 time in total
Back to top
Jerros


Newbie


Joined: 03 Jul 2010
Posts: 8

Posted: 06 Jul 2010 10:18:58 am    Post subject:

calc84maniac wrote:

[That's not a valid way to put data. I'm surprised your assembler isn't giving an error. It should be:
[
Assuming that's not the problem, where is the location of "clip_mask"?



Thats idd not the problem lol, I wasnt paying much attention there, in my real program its like its supposed to be.
I also forgot to put clip_mask there, its just in the APP, below the piece of script I posted.
Shoult it be copyd to the ram or something?

Thanks for your reply!


Last edited by Guest on 06 Jul 2010 10:31:52 am; edited 1 time in total
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 06 Jul 2010 09:30:42 pm    Post subject:

I don't know if this applies to every APP builder, but I have to include validate() as the last line of code. Also, I'll need to do a bjump(JForceCmdNoChar) to safely exit to TI-OS. Since there's no exit after the CALL ShowSprite part, the system will try to execute the sprite data and do something mean.
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 06 Jul 2010 09:37:06 pm    Post subject:

Jerros wrote:

calc84maniac wrote:

[That's not a valid way to put data. I'm surprised your assembler isn't giving an error. It should be:
[
Assuming that's not the problem, where is the location of "clip_mask"?



Thats idd not the problem lol, I wasnt paying much attention there, in my real program its like its supposed to be.
I also forgot to put clip_mask there, its just in the APP, below the piece of script I posted.
Shoult it be copyd to the ram or something?

Thanks for your reply!

clip_mask should be in RAM, yes. Otherwise the routine will try to modify flash and fail.
Back to top
Jerros


Newbie


Joined: 03 Jul 2010
Posts: 8

Posted: 07 Jul 2010 01:32:30 am    Post subject:

DigiTan wrote:

I don't know if this applies to every APP builder, but I have to include validate() as the last line of code. Also, I'll need to do a bjump(JForceCmdNoChar) to safely exit to TI-OS. Since there's no exit after the CALL ShowSprite part, the system will try to execute the sprite data and do something mean.


Thanks for the reply, but what I've posted is of course just a small piece of the programm, not the whole thing.
I'ts not nessecary to post the whole header + a complete working programm.

calc84maniac wrote:

[clip_mask should be in RAM, yes. Otherwise the routine will try to modify flash and fail.


That will be the problem then, but when do I move and read it from the ram?
I mean, where in the script do I copy it to the ram, and how/where do I "read" it?

Like I said, don't underestimate my newbyness here Rolling Eyes
Thanks for the help.
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 08 Jul 2010 12:29:40 pm    Post subject:

You need to define all of your variables in RAM somewhere, like this:

Code:
xpos .equ appbackupscreen
ypos .equ xpos+1
clip_mask .equ ypos+1


There is no actual copying going on, you simply have the variables in a different location (in the safe-to-use area of appbackupscreen)
Back to top
Jerros


Newbie


Joined: 03 Jul 2010
Posts: 8

Posted: 09 Jul 2010 02:10:20 am    Post subject:

calc84maniac wrote:

You need to define all of your variables in RAM somewhere, like this:

Code:
xpos .equ appbackupscreen
ypos .equ xpos+1
clip_mask .equ ypos+1


There is no actual copying going on, you simply have the variables in a different location (in the safe-to-use area of appbackupscreen)



Omg, I finally get how things work, thank you!
Just to be sure, each "+1" is a value of hF or hFF? (yes, I am THAT big of a newb)
That way I know how wether to do +1 or +2 or +whatever.
Or is the beautiful thing here that you dont need to bother with that, since you're using the previous variable +1?

EDIT:

At elast the sprites now show, though the locations are off.
This might be because I use this to keep track of the sprite locations:

Code:

xspr1:   .db   0
yspr1:   .db   64
xspr2:   .db   0
yspr2:   .db   64
xspr3:   .db   0
yspr3:   .db   64
xspr4:   .db   0
yspr4:   .db   64
xspr5:   .db   0
yspr5:   .db   64
xspr6:   .db   0
yspr6:   .db   64
xspr7:   .db   0
yspr7:   .db   64
xspr8:   .db   0
yspr8:   .db   64
xspr9:   .db   0
yspr9:   .db   64
xspr10:   .db   0
yspr10:   .db   64
xspr11:   .db   0
yspr11:   .db   64
xspr12:   .db   0
yspr12:   .db   64
xspr13:   .db   0
yspr13:   .db   64
xspr14:   .db   0
yspr14:   .db   64
xspr15:   .db   0
yspr15:   .db   64
xspr16:   .db   0
yspr16:   .db   64


Now, with your advie I defined it like:

Code:

xpos   .equ   appBackupScreen
ypos   .equ   xpos+2
clip_mask   .equ   ypos+2

xspr1   .equ   clip_mask+2
yspr1   .equ   xspr1+2
xspr2   .equ   yspr1+2
yspr2   .equ   xspr2+2
xspr3   .equ   yspr2+2
yspr3   .equ   xspr3+2
xspr4   .equ   yspr3+2
yspr4   .equ   xspr4+2
xspr5   .equ   yspr4+2
yspr5   .equ   xspr5+2
xspr6   .equ   yspr5+2
yspr6   .equ   xspr6+2
xspr7   .equ   yspr6+2
yspr7   .equ   xspr7+2
xspr8   .equ   yspr7+2
yspr8   .equ   xspr8+2
xspr9   .equ   yspr8+2
yspr9   .equ   xspr9+2
xspr10   .equ   yspr9+2
yspr10   .equ   xspr10+2
xspr11   .equ   yspr10+2
yspr11   .equ   xspr11+2
xspr12   .equ   yspr11+2
yspr12   .equ   xspr12+2
xspr13   .equ   yspr12+2
yspr13   .equ   xspr13+2
xspr14   .equ   yspr13+2
yspr14   .equ   xspr14+2
xspr15   .equ   yspr14+2
yspr15   .equ   xspr15+2
xspr16   .equ   yspr15+2
yspr16   .equ   xspr16+2

Maybe +2 isnt enough?
Or am I angering the asm gods with this?

Anyway, thanks alot, I think this will help me much further, since my game is nearly completed : )


Last edited by Guest on 11 Jul 2010 08:05:56 am; edited 1 time in total
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement