Re: A85: permanent varibles


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

Re: A85: permanent varibles




its really not that hard.  first, the score should probably be defined in
the text-memory, since that isn't permanent.  at the end of your code, you
should define the hiscore like this:

hiscore:
 .dw 0

you should use .dw if the score can be greater than 255.  next, if you want
to retrieve the hiscore to see if someone beat it, you can do something
like this:

checkscore:
 ld hl,hiscore         ; load relative adress of hiscore into hl
 ld de,(PROGRAM_ADDR)  ; load adress of program into de
 add hl,de             ; add to get absolute adress
 ld de,(hl)            ; load the hiscore into de
 ld hl,(score)         ; load the score into hl
 ROM_CALL(CP_HL_DE)    ; compare them
 jr nc,newhiscore      ; if score is greater, its a new hiscore
 ret

newhiscore:
 ld hl,hiscore
 ld de,(PROGRAM_ADDR)
 add hl,de             ; get adress of hiscore
 ld de,(score)
 ld (hl),de            ; load the new score into the hiscore
 ret

i think this all works.  if you're still not sure, you can check the source
code duckhunt for the 85.  i made a hiscore function in that so you can see
how that works.  i'm not sure if cp_hl_de is a rom call or a regular call
(or even if it exists in zshell, it probably does but you should check)

miklos

>Ok, lets say that I have a score in (score) memory variable.  How would I
>go about storing it as a permanent variable in the memory (for a
>hi-score).  Could who ever answers this please be as completeas possible.
> Thanks.  I have asked this multiple times and each time I get just a
>piece to the puzzle instead of all the pieces.  This would be for
>Z-Shell, not Rigel or Usgard.  Thank you very much.
>
>							- Mike
>
>P.S.- Has anyone emailed chut@zilog.com and recieved and asm programing
>books?  I emailed him and he responded saying that the order form thing
>on the web page is selective about who it sends books to.  He also said
>that he would send me the books, but it has been a while and still no
>damn books.
>
>_____________________________________________________________________
>You don't need to buy Internet access to use free Internet e-mail.
>Get completely free e-mail from Juno at http://www.juno.com
>Or call Juno at (800) 654-JUNO [654-5866]



Follow-Ups: References: