USER subroutine: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
The USER subroutine (not called, always jumped to by the BIOS) is required 68K code which needs to perform actions according to the command value set in {{BR|USER_REQUEST}}.
The USER subroutine (not called, always jumped to by the BIOS) is required [[68k]] code which needs to perform actions according to the command value set in {{BR|BIOS_USER_REQUEST}}.


At the end of the routine, a jump to BIOSF_SYSTEM_RETURN is needed to give back control to the BIOS.
At the end of the routine, a jump to [[SYSTEM_RETURN|BIOSF_SYSTEM_RETURN]] is needed to give back control to the BIOS.
 
=Handling code=
 
<syntaxhighlight>
JT_User:
    dc.l  StartupInit
    dc.l  EyeCatcher
    dc.l  Game
    dc.l  Title
 
User:
    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)
    jmp    BIOSF_SYSTEM_RETURN
</syntaxhighlight>


=USER_REQUEST values=
=USER_REQUEST values=
Line 8: Line 28:
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]]).
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 to 0 during operations, and don't forget to kick the watchdog as interrupts are disabled.
Set {{BR|BIOS_USER_MODE}} to 0 during operations, and don't forget to kick the watchdog as interrupts are disabled.
 
(The DIPs settings in RAM should then be copied to backup RAM by calling what function ?)


Initilization of the rest of the user RAM, the display, and I/O.
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:
[[Viewpoint]], which has its backup RAM save pointer set to $100000 (header $10E) and game save size set to $0200 (header $112) does this:
<syntaxhighlight>
<syntaxhighlight>
move.b #$00,BIOS_USER_MODE
move.b #$00,BIOS_USER_MODE
Line 40: Line 58:


==Command 3==
==Command 3==
Show the game's title screen. This is called when a coin is inserted on MVS systems.
Show the game's title screen. This is called when a coin is inserted on [[MVS systems]].
{{BR|BIOS_COMPULSION_TIMER}} is used as a count-down timer for auto-start.
{{BR|BIOS_COMPULSION_TIMER}} is used as a count-down timer for auto-start.


[[Category:Code]]
[[Category:Code]]

Revision as of 18:03, 5 January 2014

The USER subroutine (not called, always jumped to by the BIOS) 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

JT_User:
    dc.l   StartupInit
    dc.l   EyeCatcher
    dc.l   Game
    dc.l   Title

User:
    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)
    jmp     BIOSF_SYSTEM_RETURN

USER_REQUEST values

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
.cl:
	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

Command 1

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

More information needed (end flag, BIOS_USER_MODE value ?).

Command 2

Show the game's demo (the recommended duration is ?).

Command 3

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