Re: A85: scoring


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

Re: A85: scoring



>Depends what OS you are using.
>
>For Usgard, the premire OS (heh gotta put that in somewhere, don't I):

I've looked at these code fragments and don't think they are a good 
idea.  One of them doesn't seem to work at all, and the others could
be made a little smaller.

>; this is for 2 byte score, 0-65535
>GetScore:
>ld	hl, &score
>call	LD_HL_MHL
>; hl has your score in it

You don't need all of that.  If you want smaller, faster code, you
could just use

 ld hl,(&score)

instead.  With relocation you can read words directly from your
program code.

>; have your score in bc
>WriteScore:
>ld	hl, &score
>ld	(hl), bc
>; it's saved

I don't think this even works.  TASM gives an error when it
sees "ld (hl), bc", because the Z-80 just doesn't have an instruction
like that.  You should be using

 ld (&score),bc

If you must save to the address in HL, you can use code like this:

 ld (hl),c
 inc hl
 ld (hl),b

>; the following are for 1 byters
>ReadScore:
>ld	hl, &score
>ld	a, (hl)
>; a has your score

Again, you could just use "ld a,(&score)"

>; to write, have score in a
>WriteScore:
>ld	hl, &score
>ld	(hl), a
>; score written

And here, "ld (&score),a".


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com