<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Wed, 27 Oct 2004 12:35:14 +0100
From   : Richard_Talbot-Watkins@...
Subject: Re: &D00

John Kortink wrote on 27/10/2004 11:49:32:

> On Wed, 27 Oct 2004 11:31:54 +0100, Richard_Talbot-Watkins@...
> wrote (and then re-edited):
>
> > Even more cunning is just to push the return address yourself, i.e.
> >
> > LDA #(return_addr-1)DIV256:PHA
> > LDA #(return_addr-1)AND255:PHA
> > JMP (vector)
> > .return_addr
> > <rest of code>
> >
> > Then the routine pointed to by 'vector' can exit simply via RTS.
> > (maybe I've pushed that return address the wrong way round, I can't
> > remember).
>
> I think the intended order is <vectored routine> <whatever>,
> not the other way around, as you have here.

I've re-edited my message so what I meant is a bit clearer :)

I think the intention was just to fake a JSR (vector) type construct.
Using the method above, everything is known at assembly time.

Anyway, for code in RAM, it's even cheaper just to write:

LDA vector:STA jsr+1
LDA vector+1:STA jsr+2
.jsr JSR &FFFF
<rest of code>

...as I did, often.  Code like this often cropped up in game update code:

.UpdateMonsters
LDY #15     \\ Y is index into array of active monsters
.MonsterTableLoop
LDX MonsterSpeciesTable,Y   \\ X = 'species' of monster[Y]
BEQ NoMonsterHere     \\ if no monster in this slot, continue
LDA MonsterLogicTableLo-1,X: STA JsrMonsterLogic+1
LDA MonsterLogicTableHi-1,X: STA JsrMonsterLogic+2
.JsrMonsterLogic JSR &FFFF
.NoMonsterHere
DEY
BPL MonsterTableLoop
RTS

\\ Declare entry points to the 3 monster species' update
.MonsterLogicTableLo
EQUB ZombieLogic AND 255
EQUB GhostLogic AND 255
EQUB JellyfishLogic AND 255
.MonsterLogicTableHi
EQUB ZombieLogic DIV 256
EQUB GhostLogic DIV 256
EQUB JellyfishLogic DIV 256

Pah!  Who needs C++?



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster@...

This footnote also confirms that this email message has been checked
for all known viruses.

**********************************************************************
Sony Computer Entertainment Europe
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>