USER subroutine

From NeoGeo Development Wiki
Jump to: navigation, search

The USER subroutine (not called, always jumped to by the system ROM) is required 68k code which needs to perform actions according to the command value set in BIOS_USER_REQUEST ($10FDAE ) .

At the end of the routine, a jump to BIOSF_SYSTEM_RETURN is needed to give back control to the BIOS.

Handling code

    dc.l   StartupInit
    dc.l   EyeCatcher
    dc.l   Game
    dc.l   Title

    move.b  d0,REG_DIPSW
    clr.l   d0
    move.b  BIOS_USER_REQUEST,d0
    lsl.b   #2,d0
    lea     JT_User,a0
    movea.l (a0,d0),a0
    jsr     (a0)


Command 0

Initilization of the soft/debug DIPs in the 68k user RAM. Used only once, when the game is started for the first time on a MVS system (probably when the BIOS doesn't find the game's NGH number in the backup RAM).

Set BIOS_USER_MODE ($10FDAF ) to 0 during operations, and don't forget to kick the watchdog as interrupts are disabled.

Initilization of the rest of the user RAM, the display, and I/O.

Viewpoint, which has its backup RAM save pointer set to $100000 (header $10E) and game save size set to $0200 (header $112) does this:

	move.b	#$00,BIOS_USER_MODE
	lea	$100000,a0		;Start of game save block
	move	#$001F,d1		;32*4 longword writes = 512 bytes
	moveq	#0,d0
	move.l	d0,(a0)+
	move.l	d0,(a0)+
	move.l	d0,(a0)+
	move.l	d0,(a0)+
	dbf	d1,.cl
	move.b	d0,REG_WATCHDOG
        jmp     BIOSF_SYSTEM_RETURN

Typical use is load default data (default rankings, etc) into work-backup area, then jump to SYSTEM_RETURN.

Command 1

Show the game's own boot logo animation (when $114 = 1).

This command by default is only called on AES and not on the MVS. It is called once only at system start (before attract mode) and not again.

Later games by SNK trick the MVS bios into calling this subroutine. They do this by first moving and then executing code from RAM during their command 2 routine. This code determines the games SLOT location and then stores this location to address 0xD00058 (See routine from 0xA910E in KOF99).

A side affect is the new eye catcher does not display right away, at least one attract mode sequence must be completed first. SNK appear to have done this with the aim of updating the original spinning logo with their new version and thus this method is not advised if you want an eye catcher to show on MVS hardware. Instead it is advised to call your own the eye catcher routine from within command 2 (attract mode) only. See Aero Fighters 2 as an example, it has both the Neo Geo eye catcher and a VideoSystem eye catcher.

Command 2

Show the game's demo, this means anything related to attract mode. (the recommended duration is ?).

On AES systems the bios only comes this far and never calls command 3, if title page is required it must be done here.

Command 3

Show the game's title screen. This is called when a coin is inserted on MVS only and is never called on AES systems. BIOS_COMPULSION_TIMER ($10FDDA ) is used as a count-down timer for auto-start.

Some games write 0x01 to 0x10FEC5 in this routine. It stops the bios calling command 3 twice after game over if credits are already in the system (attract mode skipped). When 0x00 the bios will initiate another command 3 a few frames after the first. This causes the title page to draw twice. This could be a bios bug which SNK fixed by adding this variable in a later bios revision (needs confirming).

To see an example compare Art or Fighting to Art of Fighting 2 after game over.