Re: A86: saving hiscores and other data


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

Re: A86: saving hiscores and other data




Here's some code that should work:

 ld hl,progname-1
 rst 20h
 rst 10h
 ld a,b
 ld hl,highscoreoffset                ;pointer to .dw in assembly space
 add hl,de
 adc a,0
 call _load_ram_ahl                ;hl points to .dw w/ correct page swapped
                                            ;call defined in ti86abs.inc


progname:
.db 4,"golf",0                    ;name length, program name (zero-terminated)

highscoreoffset:
.dw 0                                ;area to store high scores



TGaArbvark@aol.com wrote:

> > I am having trouble saving data in my ASM program. At the end, I have the
> > line
> > HiScore:      .dw $0000  This is the high score. I use ld hl,(HighScore) to
> > retrieve the data, and it displays the right value And I use ld hl,(score) \
> > ld (HiScore),hl to save the current score as the high score. However, when I
> > exit and re-enter the program, the high score is always 0! (or whatever is
> > after .dw) Please help!
> >
> > P.S. The current score is a 2-byte value stored in (score)
>
> Whoever maintans the ticalc.org faq (Bryan?), if you're on this list,
> could you add this question?  I don't know about everyone else but
> I'm getting kinda tired of answering it.
>
> Here's a copy of a letter I sent to this list just over a week ago:
>
> > When you run an
> > assembly program, it is copied to _asm_exec_ram, a portion of
> > memory dedicated to running assembly programs, and run there.
> > All of the .db's and such are copied with the program.  When you
> > change the values in those .db's, it changes them in the current
> > program, which is the copy in _asm_exec_ram, not the actual
> > program.  When the program finishes, it is NOT copied back,
> > meaning any changes made to the copy in _asm_exec_ram
> > are lost.  To have working high scores, you have to write a
> > routine that changes the .db's in the actual program instead
> > of the copy in _asm_exec_ram.  This is harder to do and does
> > use a bit more code.




References: