Re: LZ: How to do self-modifying code?


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

Re: LZ: How to do self-modifying code?



On Tue, 27 Aug 1996, Peter Cordes wrote:


> Jimmy Mardell wrote:
> >
> > Ryan Myers wrote:
> > >
> > > How do make code that's self modifying ( for high scores? )
> >
> > It's very easy. Just change the byte (or word) in the code and do this
> > before the programs exit:
> >
> >  ld hl,ZS_BITS  ; Alias for $8C40
> >  set 0,(hl)
> >
> > Then ZShell will update the checksum so you won't get ***BAD CHECKSUM***
> > next time you try to run the game.
> what i think he wants to know is a routine that would allow that because
> he can't figure that out(neither can i).
> PCoMP
> Visit Maximus Productions home page at: http://www.ntsource.com/~pcomp
>


No, I got that one.  It's simply a matter of placing a label where you
want the score to be, kinda like this:


(rest of program)
HighScore:
	.db	"Ryan The Almighty Master",0 :)
	.db	999999999


and have the program end by altering that part of the code then
recomputing the checksum ( so ZS doesn't throw a fit ) and then loading
that part of the code at the beginning.  I think... I am going to take a
look at the code of other programs and see.


It's the part of altering that code that's tricky.  I think it's a matter
of using the label location in memory to directly shove the name and score
in.  Anyone correct me if I'm wrong.


Ryan Myers
rmyers@teleport.com
http://www.teleport.com/~rmyers/
-- "One useless man is a disgrace.  Two useless men are a burden to
-- society.  Three or more useless men means Congress is in session."


References: