View Single Post
Old 16 September 2014, 00:56   #34
AnimaInCorpore
Registered User
 
Join Date: Nov 2012
Location: Willich/Germany
Posts: 233
Here are the sources for Galaga 88 and Pac-Mania. Both can be assembled with the Human68k toolchain to build executables which will work on the X68000 again.

The additional data files for Galaga 88 can be found in the release for the Atari Falcon (in fact no data has been modified in any way so the files from the original game disks will work as well).

Some notes about the changes to get Galaga 88 running virtually on the Amiga:

Remove the fixed address labels in the header and add the following BSS data. Please note that many memory mapped areas are not used and therefore they've been commented out ("|"). However, the VRAM is always 2 MiB in size due to the special graphics memory map layout so you'll need quite a lot of RAM even for a simple port without graphics emulation.

Code:
L_00C00000:   | VRAM
	ds.b    0x200000
L_00E00000:   | TEXT PLANE 1
	ds.b    0x20000
L_00E20000:   | TEXT PLANE 2
	ds.b    0x20000
L_00E40000:   | TEXT PLANE 3
	ds.b    0x20000
L_00E60000:   | TEXT PLANE 4
	ds.b    0x20000
L_00E80000:   | CRTC
	ds.b    0x2000
L_00E82000:   | VIDEO CONTROLLER
	ds.b    0x2000
|L_00E84000:   | DMAC
|	ds.b    0x2000
|L_00E86000:   | AREA
|	ds.b    0x2000
L_00E88000:   | MFP
	ds.b    0x2000
|L_00E8A000:   | RTC
|	ds.b    0x2000
|L_00E8C000:   | PRINTER
|	ds.b    0x2000
L_00E8E000:   | SYSTEM PORT
	ds.b    0x2000
|L_00E90000:   | FM
|	ds.b    0x2000
|L_00E92000:   | ADPCM
|	ds.b    0x2000
L_00E94000:   | FDC
	ds.b    0x2000
|L_00E96000:   | HDD
|	ds.b    0x21
|L_00E96021:   | SCSI (HDD)
|	ds.b    0x1FDF
|L_00E98000:   | SCC
|	ds.b    0x2000
L_00E9A000:   | I/O
	ds.b    0x4000
|L_00E9E000:   | FPU
|	ds.b    0x2000
|L_00EA0000:   | SCSI
|	ds.b    0xF900
|L_00EAF900:   | FAX
|	ds.b    0x100
|L_00EAFA00:   | MIDI 1
|	ds.b    0x10
|L_00EAFA10:   | MIDI 2
|	ds.b    0xF0
|L_00EAFB00:   | (ToDo)
|	ds.b    0x500
L_00EB0000:   | SPRITE REGISTERS
	ds.b    0x8000
L_00EB8000:   | SPRITE VRAM
	ds.b    0x8000
|L_00EC0000:   | USER I/O
|	ds.b    0x10000
L_00ED0000:   | SRAM
	ds.b    0x4000
|L_00ED4000:   | 'PRELIMINARY'
|	ds.b    0x1C000
|L_00EF0000:   | 'UNUSED'
|	ds.b    0x10000
|L_00F00000:   | CG ROM
|	ds.b    0xC0000
|L_00FC0000:   | 'PRELIMINARY'
|	ds.b    0x20000
|L_00FE0000:   | IPL ROM
|	ds.b    0x20000
Search for instructions accessing "0x18.l", "0xb8.l", 0x118.l" and "0x130.l". Remap them to BSS data labels as well. I noticed that I have not changed those addresses in the source linked above.

Now you should be able to compile the code. You probably need to cleanup the code a bit to meet your assembler syntax demands.

The next step is to add functions to simulate X68000 OS calls. To do so add a handler for TRAP #15 and LINEF like shown in the following code:

Code:
line_f:
	movem.l	d1-d2/a0-a2,-(sp)

	move.l	22(sp),a0
	move	(a0),d0
	addq.l	#2,22(sp)

	cmp		#0xff3d,d0
	bne		line_f_not_open

	move.l	26+LINE_F_OFFSET+0(sp),a0
	move	26+LINE_F_OFFSET+4(sp),d0

	move.w	d0,-(sp)
	pea		(a0)
	move.w	#61,-(sp)
	trap	#1
	addq.l	#8,sp

	bra		line_f_exit

line_f_not_open:
	cmp		#0xff3f,d0
	bne		line_f_not_read

	move	26+LINE_F_OFFSET+0(sp),d0
	move.l	26+LINE_F_OFFSET+2(sp),a0
	move.l	26+LINE_F_OFFSET+6(sp),d1
	and.l	#0x7fffffff,d1

	pea		(a0)
	move.l	d1,-(sp)
	move	d0,-(sp)
	move	#63,-(sp)
	trap	#1
	lea		12(sp),sp

	bra		line_f_exit

line_f_not_read:
	cmp		#0xff3e,d0
	bne		line_f_not_close

	move	26+LINE_F_OFFSET+0(sp),d0

	move.w	d0,-(sp)
	move.w	#62,-(sp)
	trap	#1
	addq.l	#4,sp

	bra		line_f_exit

line_f_not_close:

	clr.l	d0
line_f_exit:
	movem.l	(sp)+,d1-d2/a0-a2

	rte

trap_f:
	cmp		#17,d0
	bne		trap_f_not_contrast

	move	#15,d0

	rte

trap_f_not_contrast:
	cmp		#22,d0
	bne		trap_f_not_fntadr

	move.l	#draw_text_overlay+1024*512/8,d0 | Simply a valid dummy address (font address) where write accesses don't hurt much.

	rte

trap_f_not_fntadr:
	cmp		#0x21,d0
	bne		trap_f_not_b_print

	movem.l	d0-d2/a0-a2,-(sp)

	pea		(a1)
	move.w	#9,-(sp)
	trap	#1
	addq.l	#6,sp

	movem.l	(sp)+,d0-d2/a0-a2

	rte

trap_f_not_b_print:
	cmp		#0x60,d0
	bne		trap_f_not_adpcmout

	rte

trap_f_not_adpcmout:
	cmp		#0x6c,d0
	bne		trap_f_not_vdispst

	cmp.l	#0,a1
	bne		trap_f_vdispst_set

	move.l	a1,L_00000118
	clr.l	d0

	rte

trap_f_vdispst_set:
	clr.l	L_00000118
	clr.l	d0

	rte

trap_f_not_vdispst:
trap_f_exit:
	clr.l	d0

	rte
As you can see there's not much to do. Just fopen(), fread() and fclose() need to be simulated in the LINEF handler (here: mapped to Atari Trap #1 calls) also setting the X68000 VBL handler is the only important function in the TRAP #15 handler. I would suggest to replace the calls within the source directly with the appropriate Amiga DOS functions. However, please note the dummy return values of the remaining TRAP #15 and LINEF calls which the callee expect.

To disable the sound we need to comment out all TRAP #1 calls.

In the next step we will add timing functions. Setup a VBL routine and call the function at L_00000118 if the vector is not 0 (see TRAP #15 handler for the original VBL handler setup).

Alter the COUNT_VDISP_LOW_HIGH_STATE like shown in the following code snippet. This needs to be done because the function tests a VBL state flag which can be replaced by a simpler function.

Code:
COUNT_VDISP_LOW_HIGH_STATE:
wait_for_vbl:		| fixme
	addq.b	#3,70(a4)
	addq.b	#3,72(a4)
	tst	vbl_counter
	beq.s	wait_for_vbl
	clr	vbl_counter
	rts
Also add a VBL wait to the WAIT_FOR_VDISP_SET_AND_CLEAR_SPRITE_POSITIONS routine as well. Replace the first six lines of code:

Code:
WAIT_FOR_VDISP_SET_AND_CLEAR_SPRITE_POSITIONS:
	addq.b  #0x3,70(%A4)                            | 0x0002BB32 562C 0046                | S(0x00029C28)
	btst    #0x4,L_00E88000+0x1.l                   | 0x0002BB36 0839 0004 00E8 8001      | [MFP + 0x1]
	beq.s   WAIT_FOR_VDISP_SET_AND_CLEAR_SPRITE_POSITIONS                              | 0x0002BB3E 67F2                     |

L_0002BB40:
	addq.b  #0x3,72(%A4)                            | 0x0002BB40 562C 0048                |
	btst    #0x4,L_00E88000+0x1.l                   | 0x0002BB44 0839 0004 00E8 8001      | [MFP + 0x1]
	bne.s   L_0002BB40                              | 0x0002BB4C 66F2                     |
with:

Code:
WAIT_FOR_VDISP_SET_AND_CLEAR_SPRITE_POSITIONS:
wait_for_vbl:
	addq.b	#3,70(a4)
	addq.b	#3,72(a4)
	tst	vbl_counter
	beq.s	wait_for_vbl
	clr	vbl_counter
Finally before starting the main routine of Galaga 88 you need to initialise the virtual joystick data so that the attract mode will not be interrupted:

Code:
	move.b	#0xff,L_00E9A000+0x1.l	| Joystick 1 button and direction bits are inverted.
	move.b	#0xff,L_00E9A000+0x3.l	| Joystick 2 button and direction bits are inverted.
So now the game should run in a attract mode loop internally. As you can see there's not really changed much in the original source. At least the strategy works for Pac-Mania so far as well.

I'm not sure if I have missed something. Some time has passed since the port but I think that were the most important steps to have a good starting point.
AnimaInCorpore is offline  
 
Page generated in 0.05001 seconds with 11 queries