Re: A86: Efficiency Problem
[Prev][Next][Index][Thread]
Re: A86: Efficiency Problem
In a message dated 12/10/98 5:53:45 PM Pacific Standard Time,
ZeromusMog@aol.com writes:
> The following is a fragment(?) of code from a game I'm working on called
Nerd
> Quest I. It's the a part that displays the current weapon on the status
> screen. It seems to me that this code is incredibly ineffiecient, and
there'
> s
> gotta be a faster way of doing this. (Perhaps by using that evil call-
> counting
> thing mentioned earlier?) BTW, if any of you have suggestions for "nerd"
> weapons, I'd like to hear them! (I'm especially interested in "single-use"
> type ones, e.g. HCl, Test Tube, Inhaler, Bottle Rocket, etc.)
>
> Now, the inefficient code!
>
> GameLoop:
> call CLS ;byte-saving thing
> ...
> ...
> ld a,(Weapon) ;Weapon EQU $F602
> cp 0
> call z,Wp1
> cp 1
> call z,Wp2
> cp 2
> call z,Wp3
> cp 3
> call z,Wp4
> cp 4
> call z,Wp5
> cp 5
> call z,Wp6
> cp 6
> call z,Wp7
> cp 7
> call z,Wp8
> cp 8
> call z,Wp9
> cp 9
> call z,Wp10
> cp 10
> call z,Wp11
> cp 11
> call z,Wp12
> cp 12
> call z,Wp13
> cp 13
> call z,Wp14
> cp 14
> call z,Wp15
> cp 15
> call z,Wp16
> call _puts
> ...
> jp Somewhere
>
> Wp1:
> ld hl,W1
> ret
>
> Wp2:
> ld hl,W2
> ret
>
> Wp3:
> ld hl,W3
> ret
>
> Wp4:
> ld hl,W4
> ret
>
> Wp5:
> ld hl,W5
> ret
>
> Wp6:
> ld hl,W6
> ret
>
> Wp7:
> ld hl,W7
> ret
>
> Wp8:
> ld hl,W8
> ret
>
> Wp9:
> ld hl,W9
> ret
>
> Wp10:
> ld hl,W10
> ret
>
> Wp11:
> ld hl,W11
> ret
>
> Wp12:
> ld hl,W12
> ret
>
> Wp13:
> ld hl,W13
> ret
>
> Wp14:
> ld hl,W14
> ret
>
> Wp15:
> ld hl,W15
> ret
>
> Wp16:
> ld hl,W16
> ret
>
> ... ;Whole Lotta Code!
>
> ;Data Section
> W1: .db "AOL Disk",0
> W2: .db "Pocket Protector",0
> W3: .db "Uniball Pen",0
> W4: .db "Ruler",0
> W5: .db "Ugly Stick",0
> W6: .db "Old Game Boy",0
> W7: .db "Linux Reference Book",0
> W8: .db "Linux CD",0
> W9: .db "Cokebottle Glasses",0
> W10: .db "AP Calc Textbook",0
> W11: .db "MS Intellimouse",0
> W12: .db "Macintosh LC",0
> W13: .db "Overhead Projector",0
> W14: .db "TI-92+",0
> W15: .db "486 Motherboard",0
> W16: .db "Soldering Iron",0
So how come at
> cp 0
> call z,Wp1
you don't put
> cp 0
> call z,.db "AOL Disk",0
Can you do this or do you have to go through all of that?
-Ameise