Re: A86: HI.


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

Re: A86: HI.




Don't do it like that! Program writeback is bad! Save the variables in a
hidden variable, such as %game (replacing "game" with a distinctive title
for your game). This has a few advantages, the biggest of which is that if
the game is transferred to another calculator, the data doesn't go with it,
which is (almost always) a good thing.
----- Original Message -----
From: David Phillips <david@acz.org>
To: <assembly-86@lists.ticalc.org>
Sent: Friday, December 10, 1999 11:55 PM
Subject: Re: A86: HI.


> Write back.  Store the variables inside your program like this:
>
> GameSaveData:         ; put this somewhere like the end of your program
> ...
> PlayerMoney: .dw 0
> PlayerLevel: .dw 0
> ...
> GameSaveDataSize = $ - GameSaveData
>
> Then write it back with a routine like this:
>
>  ld hl,ProgramVar-1
>  rst 20h
>  rst 10h
>  call _ex_ahl_bde
>  ld de,GameSaveData-_asm_exec_ram+4
>  add hl,de
>  adc a,0
>  call _set_abs_dest_addr
>  sub a
>  ld hl,GameSaveData
>  call _set_abs_src_addr
>  ld hl,GameSaveDataSize
>  call _set_mm_num_bytes
>  call _mm_ldir
>  ret
>
> ProgramVar:
>  .db 4,"name"       ; 4 is the number of chars in 'name', which is the
> program variable's name
>
> Note that I haven't done any 86 coding in a while and I just ripped this
> from my last project, so there could be a more optimized way...




Follow-Ups: References: