From: psteffn@hal.gnu.ai.mit.edu (Paul Steffen)
Newsgroups: alt.sys.amiga.demos
Subject: Amiga Action Replay in Software
Date: 12 Dec 1992 08:30:16 GMT
Organization: /etc/organization
NNTP-Posting-Host: hal.gnu.ai.mit.edu

Newsgroups: alt.sys.amiga.demos
Subject: Action Replay emulator?  (src)
Summary: 
Expires: 
Followup-To: 
Distribution: Tibetan Peach Pie Inc.
Organization: /etc/organization
Keywords: 


It's been a long time since I read alt.sys.amiga.demos!  Anyway,
I noticed some mention of utilizing the 68010 relocatable vector table
capability as a 'software Amiga Replay'to break most games and demos.
I've been using this trick to display system info (i.e. dma channels,
exception vectors, etc) in real-time on a terminal connected to the
Amiga via RS232.

Here's some tacky source that I wrote some time ago.  I cleaned it up
a bit and added comments where necessary.  Modify VECTOR to point to
high fast mem for your system (if necessary), assemble and execute.
The computer should pause whenever both the left mouse and fire buttons
are pressed, even in just about all Amiga demos with the exception of
few '010+ aware ones like Cube-O-Matic.

The original version I wrote was MUCH smaller because it only used a
single exception handler and used the unused upper 8-bits of the '10
program counter to store exception number.  This version is an untested
but I'm assuming this will run on an 68020-68040 with cache off and
initial VBR at 0 (which should NEVER be a problem under AmigaDOS).

Watch out for the "Americans Can't Code" demo by TPPi.  d:^)

Happy gurus!


*	VBR-base handler generator!  by STratoHAK/TPPi
*	Paul Steffen/psteffn@gnu.ai.mit.edu/4086332274
*       9/5/92
*
*	
*  monitor =  0 to just halt / 1 to jmp to adrs in monitor_entry
*  monitor_entry = entry for monitor/debugger
*  vectors = new vector base + irq handlers {very top of FAST mem is best}

vectors = $3b0000
monitor = 0
monitor_entry = $3e0008

	lea	check_user(pc),a0
	lea	vectors,a1
	move.l	#irq_e-interrupt_handler,d0
	lsl.w	#8,d0
	add.l	#1024,d0
	add.l	d0,a1
	lea	chk_e(pc),a2
copy_subrout
	move.w	(a0)+,(a1)+
	cmp.l	a0,a2
	bne.s	copy_subrout

	lea	vectors,a1	; interrupt vector table
	lea	256*4(a1),a2	; interrupt handlers
	lea	irq_e(pc),a4
	moveq	#0,d0
	
build_irq_table	


	lea	interrupt_handler(pc),a0
	move.l	a2,(a1)+

	move.w	d0,relocat-interrupt_handler+2(a0)
	lea	relocat-interrupt_handler+10(a2),a3
	move.l	a3,relocat-interrupt_handler+4(a0)
make_irq
	move.w	(a0)+,(a2)+
	cmp.l	a0,a4
	bne.s	make_irq
	addq.w	#4,d0
	cmp.w	#1024,d0
	bne.s	build_irq_table

	lea	set_vbr(pc),a0	; set vector base register
	move.l	a0,$80.w
	trap	#0
	clr.l	d0
	rts

*	Actual IRQ interception handler...
*	(odd, but no register usage)

interrupt_handler
*
* anything can go here but to save space, JSR
*
	jsr	check_user
relocat	move.l	0.w,0.l		; modify following opcode
	jmp	0.l
irq_e

*	Test left mousebutton/joystick 1 fire for press & release

check_user
	btst	#6,$bfe001
	bne.s	no_button
	btst	#7,$bfe001
	bne.s	no_button
depress	btst	#6,$bfe001
	beq.s	depress
	btst	#7,$bfe001
	beq.s	depress

	ifne	monitor
	jsr	monitor_entry
	endif

no_button
	rts

set_vbr	lea	vectors,a0
	dc.l	$4e7b8801	* movec a0,vbr *
	rte

reset_vbr
	sub.l	a0,a0
	dc.l	$4e7b8801	* movec a0,vbr *
	rte	
chk_e

----------------------------------------------------------------------


Newsgroups: alt.sys.amiga.demos