hardware reset freeze megadrive

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

hardware reset freeze megadrive

Post by Pascal » Mon Jan 15, 2007 10:22 am

Hello all,

i've a little problem in my game, when the user push the reset button, that freeze totaly my megadrive. Do you have idea of what can causing such behavior ? i'm was not doing any z80 bus acces at that time. Maybe DMA...

thanks in advance

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Jan 15, 2007 10:36 am

Do you have the same problem with Fusion emulator and using the soft reset feature ? is your initialisation procedure testing about soft reset (genrally by testing the controller port setting A10008) ?
Maybe your program initialisation states up on the initial power ON genesis state.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon Jan 15, 2007 10:38 am

In which language your program is written ??? I had problems with uninitialized variables (now I initialize everything not leave as is) which caused some erratic behaviour in one of my ASM program.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Mon Jan 15, 2007 11:06 am

i'm using asm with snasm68k

Stef: i've tried and kega soft reset do exactly the same. i'm using the classic startup code:

Code: Select all

MD_Startup_Code:
	tst.l	$a10008
	bne	SkipJoyDetect
	tst.w	$a1000c
SkipJoyDetect:
	bne	SkipSetup
	lea	Table,a5
	movem.w	(a5)+,d5-d7
	movem.l	(a5)+,a0-a4
	move.b	-$10ff(a1),d0		;Check Version Number
	andi.b	#$0f,d0
	beq	WrongVersion
	move.l  #$53454741,$2f00(a1)	;Sega Security Code (SEGA)
WrongVersion:
	move.w  (a4),d0
	moveq   #$00,d0
	movea.l d0,a6
	move    a6,usp
	moveq   #$17,d1			;Set VDP registers
FillLoop:
	move.b  (a5)+,d5
	move.w  d5,(a4)
	add.w   d7,d5
	dbra    d1,FillLoop                           
	move.l  (a5)+,(a4)                            
	move.w  d0,(a3)                                 
	move.w  d7,(a1)                                 
	move.w  d7,(a2)                                 
L0250:
	btst    d0,(a1)
	bne     L0250                                   
	moveq   #$25,d2                ; Put initial vaules into a00000                
Filla:                                 
	move.b  (a5)+,(a0)+
	dbra    d2,Filla
	move.w  d0,(a2)                                 
	move.w  d0,(a1)                                 
	move.w  d7,(a2)                                 
L0262:
	move.l  d0,-(a6)
	dbra    d6,L0262                            
	move.l  (a5)+,(a4)                              
	move.l  (a5)+,(a4)                              
	moveq   #$1f,d3                ; Put initial values into c00000                  
Filc0:                             
	move.l  d0,(a3)
	dbra    d3,Filc0
	move.l  (a5)+,(a4)                              
	moveq   #$13,d4                ; Put initial values into c00000                 
Fillc1:                            
	move.l  d0,(a3)
	dbra    d4,Fillc1
	moveq   #$03,d5                ; Put initial values into c00011                 
Fillc2:                            
	move.b  (a5)+,$0011(a3)        
	dbra    d5,Fillc2                            
	move.w  d0,(a2)                                 
	movem.l (a6),d0-d7/a0-a6                    
	move    #$2700,sr
SkipSetup:
	bra     Continue
Table:
	dc.w    $8000, $3fff, $0100, $00a0, $0000, $00a1, $1100, $00a1
	dc.w    $1200, $00c0, $0000, $00c0, $0004, $0414, $302c, $0754
	dc.w    $0000, $0000, $0000, $812b, $0001, $0100, $00ff, $ff00
	dc.w    $0080, $4000, $0080, $af01, $d91f, $1127, $0021, $2600
	dc.w    $f977, $edb0, $dde1, $fde1, $ed47, $ed4f, $d1e1, $f108
	dc.w    $d9c1, $d1e1, $f1f9, $f3ed, $5636, $e9e9, $8104, $8f01
	dc.w    $c000, $0000, $4000, $0010, $9fbf, $dfff

Continue:
	tst.w    $00C00004
	move.w  #$2300,sr			; user mode
	lea     $ff0000,a0			; clear Genesis RAM
	moveq   #0,d0
clrram: move.w  #0,(a0)+
	subq.w  #2,d0
	bne     clrram
	
	jmp	_main
i didn't found any doc that a10008 was for the reset

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Jan 15, 2007 11:14 am

Just by reading the source code, you can see that if $(A10008).l or $(A1000C).w return something != 0
then you pass all the initialisation process (SkipSetup) and only the RAM will be cleared (the VDP and Z80 aren't re initialised).

I guess your main function assumes all is initialised as after Power ON, but after a soft reset only the main RAM will be cleared because A10008 or/and A1000C are != 0

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Mon Jan 15, 2007 12:41 pm

thanks to your point that kega might reproduce the behaviour, i get to the conclusion that the problem is the joypad initialisation, after the ram is cleared, i initiliaze the joypad using the following code :

Code: Select all

PAD3_Init:
	moveq	#$40,d0
	move.b	d0,$a10009
	move.b	d0,$a1000b
	move.b	d0,$a1000d
...
	rts
if i comment those lines, the rom reset properly (but no joypad anymore). What's the best way to handle joypad initialization ?

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Mon Jan 15, 2007 1:44 pm

i found the problem, thanks for your clues stef , it was that interrupts were still activated when i reset. But i needed to redo all the vdp,vram,... clearing , else my rom gonna glitch.

now i'm wondering why the startup code was skipping the initialize of vdp and vram when there's a reset ?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon Jan 15, 2007 1:45 pm

Wierd ... In GBMD (my game) joypads (and the rest of the stuff) are reinitialized exactly the same way every time the game starts or is reset. I've never experienced any lockups, maybe because I don't initialize 3rd port or I use my own written from scratch routines ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Mon Jan 15, 2007 2:07 pm

nop, except the startup code , it's all my code ;)

but i was reading the joypad during every VBLANK. So as interrupts where not disable my pad reading routine was still active. and during it, i was trying to jump to an unknow location (i'm using a pointer in ram). So now i've handle it properly by disabling the int at the very start

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon Jan 15, 2007 2:15 pm

Now I see... :)

I have written the startup code (and the rest) from scratch. My joypad code just stores the result in RAM.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Jan 15, 2007 2:20 pm

Pascal wrote:i found the problem, thanks for your clues stef , it was that interrupts were still activated when i reset. But i needed to redo all the vdp,vram,... clearing , else my rom gonna glitch.

now i'm wondering why the startup code was skipping the initialize of vdp and vram when there's a reset ?
I guess the startup code does that just for cohenrency about the term "software reset". A software reset shouldn't reset hardware ;)
Some game uses software reset and acts differently than for hardware reset.

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Mon Jan 15, 2007 2:36 pm

I see, i reseted everything to be sure :D things are coming along nicely, i'll release surely something this week :P

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Jan 16, 2007 1:45 pm

Any hints on what you'll release ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Tue Jan 16, 2007 2:03 pm

sure it's the demo of
http://www.spoutnickteam.com/ST/viewgames.php3?id=3

i got the first beta, need to heavily test it on the hard and write a manual (boooring ^^)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Jan 16, 2007 2:11 pm

:D
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Post Reply