Console freezes when reset

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Jpg3D
Interested
Posts: 20
Joined: Mon Mar 03, 2014 9:19 pm

Console freezes when reset

Post by Jpg3D » Sat Jul 15, 2017 5:56 pm

Hi again to everyone.

I know i'm not a really active member of this community. But i would like to converse about a bug that i found at one of my roms.

This bug just consists that the console freezes after pressing the reset button several times very fast. Then sometimes the console completely freezes and i need to turn off and on to get it working again.

Even if i press reset button while freezed, the console will ignore the reset signal.

Im actually wondering if maybe reset the console just while a dma operation is active can freeze the system because i write to vdp registers to set up the system. But adding a dma wait to the start of the program did not solve this error. So actually i have not any idea why this is happening.

What kind of programming error can explain this behaviour?

User avatar
flamewing
Interested
Posts: 36
Joined: Tue Sep 23, 2014 2:39 pm
Location: France

Re: Console freezes when reset

Post by flamewing » Sat Jul 15, 2017 8:37 pm

A random idea: if you add a read from the VDP control port before doing any writes to it, does the issue still happen?

User avatar
Natsumi
Very interested
Posts: 81
Joined: Mon Oct 05, 2015 3:00 pm
Location: 0x0
Contact:

Re: Console freezes when reset

Post by Natsumi » Sat Jul 15, 2017 9:53 pm

Also something that is at the very least possible, is trying to wait for Z80 to stop when its not in a correct state, I remember getting this issue frequently when ROMs do not properly reset/initialize

Jpg3D
Interested
Posts: 20
Joined: Mon Mar 03, 2014 9:19 pm

Re: Console freezes when reset

Post by Jpg3D » Sun Jul 16, 2017 7:54 am

Natsumi wrote:
Sat Jul 15, 2017 9:53 pm
Also something that is at the very least possible, is trying to wait for Z80 to stop when its not in a correct state, I remember getting this issue frequently when ROMs do not properly reset/initialize
Actually i do not initialize z80 in any of my roms. And only this one has this effect.
flamewing wrote:
Sat Jul 15, 2017 8:37 pm
A random idea: if you add a read from the VDP control port before doing any writes to it, does the issue still happen?
Already did : (

This simplified version of the program increases this effect. After pressing reset pressing 2 or 3 the console will be completely freezed and will ignore resets after that moment.

If i move the line marked with "<====== This line" at the end of VSYNC the program wontfreeze when being resset. I dont know why because at that infinite loop i disable interrupts.

Vint:

Code: Select all


VSYNC: 
    
    MOVE.L A0,-(A7) 
    MOVE.L D0,-(A7)
    MOVE.L D1,-(A7)
    
    LEA.L $00FF0000,A0
    BSR GET6BTN            ;Function that reads buttons to 00ff0000

    MOVE.L (A7)+,D1
    MOVE.L (A7)+,D0
    MOVE.L (A7)+,A0

    RTE


Program:

Code: Select all

START:                  ;Where the program begin

        MOVE.W #$8000,D0 
        
BEGLP   NOP
        NOP
        NOP
        NOP
        DBRA D0,BEGLP ; Useless dumb loop 

        BSR DMAWAIT    <-Just in case Useless wait until vdp is avaible.
        
    		; TMSS Check
		MOVE.B	$A10001,D0 
		ANDI.B	#$0F,D0
		BEQ.B	DSTMSS	
		MOVE.L	#'SEGA',$A14000
DSTMSS:	
        
     LEA $00FF0000,A0
     
     BSR INITGMPD
  
    STVDPREG 0,%00000100  ;Disable H interrupt and HV counter
    STVDPREG 1,%01110100  ;Enable Display enable V interrupt enable DMA 28 cell mode : ( no pal
    STVDPREG 2,$30        ;Ascroll DIRECTION
    STVDPREG 3,%00000000  ;Wscroll  DIRECTION no fucks given cause i wont use this plane
    STVDPREG 4,$07        ;Bscroll  DIRECTION
    STVDPREG 5,$6C        ;Sprite table
    STVDPREG 6,%00000000  ;Phantom Register. it does nothing?
    STVDPREG 7,$0D  ;Background color pal0 color 0
    STVDPREG 8,%00000000  ;Another phantom Register. it does nothing?
    STVDPREG 9,%00000000  ;Another phantom Register. it does nothing?
    STVDPREG 10,%00000000 ;Hint every scan
    STVDPREG 11,%00000000 ;FULL VSCROLL FULL HSCROLL External interrupt disabled
    STVDPREG 12,%10000001 ;40 cell mode 
    STVDPREG 13,$37       ;hscroll table DIRECTION
    STVDPREG 14,%00000000  ;Another phantom Register. it does nothing?
    STVDPREG 15,%00000010  ;Autoincrement.Usually 2;
    STVDPREG 16,%00010001  ;Scrollplanes 64x64
    STVDPREG 17,%00000000  ;Wscroll Hposition i dont care cause i wont use this plane
    STVDPREG 18,%00000000  ;Wscroll Vposition i dont care cause i wont use this plane

    
        DMAFVS 20,$00,$0		;This macro fills vscrollram 20 words, value = 0 destination = 0;
		BSR DMAWAIT 

		DMAFVM 64000,$00,0   ;This macro fills video memory 64000 bytes, value = 0 destination = 0;
		BSR DMAWAIT
		DMAFVM $5800,$55,96
		BSR DMAWAIT

		DMAFVM 32,$00,0
		BSR DMAWAIT
		DMAFVM 32,$AA,32
		BSR DMAWAIT
		DMAFVM 32,$BB,64
		BSR DMAWAIT
		

	    BSR DMAWAIT
		DMA2CR 16,HUDPAL,0	;This macro performs DMA from Ram to Cram
        BSR DMAWAIT
        DMA2VM 16,SPRTEST,$D800	;This macro performs DMA from Ram to Vram
        BSR DMAWAIT

        MOVE.L #$00FF0040,A1	;Copy sprite value to ram
        MOVE.L #SPRTEST,A0    
        MOVE.L (A0)+,(A1)+
        MOVE.L (A0)+,(A1)+
        MOVE.L (A0)+,(A1)+
        MOVE.L (A0)+,(A1)+

        MOVE.W #$2000,SR   
        
FNLP: 
        MOVE.W #$2700,SR   
        DMA2VM 16,$00FF0040,$D800     <====== This line
        MOVE.W #$2000,SR   

    JMP FNLP

Macro that aparently bugs the code.

Code: Select all

    
DMA2VM MACRO

        STVDPINC 2 
		MOVE.W	#$9400+(((\1)>>9)&$FF),($C00004).l
		MOVE.W	#$9300+(((\1)>>1)&$FF),($C00004).l
		
		MOVE.W	#$9600+(((\2>>1)&$FF00)>>8),($C00004).l
		MOVE.W	#$9500+((\2>>1)&$FF),($C00004).l
		MOVE.W	#$9700+((((\2>>1)&$FF0000)>>16)&$7F),($C00004).l

        MOVE.L #$40000080|(((\3)&$3FFF)<<16)|(((\3)&$C000)>>14),($C00004).l
    
       ENDM
       

Chilly Willy
Very interested
Posts: 2486
Joined: Fri Aug 17, 2007 9:33 pm

Re: Console freezes when reset

Post by Chilly Willy » Sun Jul 16, 2017 2:58 pm

This is talked about in the Software Guidelines, section 3. The first thing is to always wait on the BUSY bit for the DMA after a reset. Even that isn't guaranteed to solve the issue if the reset occurred at a specific point in the bus grant handshake while starting a DMA. To solve that case, you should wait after a reset for an unspecified time period before using DMA. I tend to wait a few vblanks.

Jpg3D
Interested
Posts: 20
Joined: Mon Mar 03, 2014 9:19 pm

Re: Console freezes when reset

Post by Jpg3D » Sun Jul 16, 2017 6:39 pm

Chilly Willy wrote:
Sun Jul 16, 2017 2:58 pm
This is talked about in the Software Guidelines, section 3. The first thing is to always wait on the BUSY bit for the DMA after a reset. Even that isn't guaranteed to solve the issue if the reset occurred at a specific point in the bus grant handshake while starting a DMA. To solve that case, you should wait after a reset for an unspecified time period before using DMA. I tend to wait a few vblanks.
Thank you for that precise answer. That explains why the other rom works fine. In the other rom i boot up the system without using dma.

I didnt know about the existence of that "Software Guidelines" Where i can find that document to have a look at it?

Chilly Willy
Very interested
Posts: 2486
Joined: Fri Aug 17, 2007 9:33 pm

Re: Console freezes when reset

Post by Chilly Willy » Sun Jul 16, 2017 7:36 pm

They're in the back for the Genesis Software Manual found everywhere online. 8) Lot's of good info in the bulletins and such at the end of the manual. Corrections and issues like the DMA/reset problem.

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

Re: Console freezes when reset

Post by TmEE co.(TM) » Sun Jul 16, 2017 7:50 pm

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

Jpg3D
Interested
Posts: 20
Joined: Mon Mar 03, 2014 9:19 pm

Re: Console freezes when reset

Post by Jpg3D » Mon Jul 17, 2017 4:41 pm

Thank you for your answers!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests