[A83] Re: 3 subroutines in 1


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

[A83] Re: 3 subroutines in 1





Well, you could use 
jr z,$+5
jp GetKey

instead of the jumps you make to next labels.

but it wouldn't be effectively different from doing
jr z,enemy_moveN
jp GetKey

for these small jump it's better to use jr instead of jp.
jr is one bytes smaller than jp.

BTW,
your program already is one subroutine, since the jumps are merely
contitionals in one larger subroutine.

It's not labels that define what is a subroutine, it's the way you code,
and the purpose of the code that's a subroutine...
(One could even argue that only labels you call to are subroutines

--Peter-Martijn



On Tue, 19 Mar 2002, Matt McDole wrote:

> 
> Is there anyway to compare a value and then not have to jp to another 
> subrutine?  All three of these is ment to delay the sprite movement, and 
> then move the sprite.  I would like all three to be in one routine.  Do you 
> guys have any ideas?
> 
> 
> enemy_move:
>      ld a,(Temp)
>      inc a
>      ld (Temp),a
>      cp 100
>      jp z,enemy_move2
>      jp GetKey
> enemy_move2:
>      ld a,0
>      ld (Temp),a
>      ld a,(Temp2)
>      inc a
>      ld (Temp2),a
>      cp 100
>      jp z,enemy_move3
>      jp GetKey
> enemy_move3:
>      ld l,0
>      ld a,(EXpos)
>      ld b,8
>      ld ix,enemy_ship
>      call ionPutSprite
>      call ionFastCopy
>      ld l,0
>      ld a,(EXpos)
>      ld b,8
>      inc a
>      ld (EXpos),a
>      ld b,8
>      ld ix,enemy_ship
>      call ionPutSprite
>      call ionFastCopy
>      ld a,0
>      ld (Temp),a
>      ld (Temp2),a
>      jp GetKey
> 
> 




References: