English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 14 April 2011, 15:28   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 592
Need help finding the last bug!

Hi Guys

Well, the music disk is basically all done. Text, hidden parts, boot blocks etc. etc. etc.

I do however have one last bug. Every now and then, the disk loading routine seems to fall over. I very much doubt its bad code as it was written by our one and only Stingray. I think it might be a conflict between the CIA interrupt used for the protracker replay and the CIA timers used in the loader code.

I have switches which convert the music disk into a single file, so all the data is in memory and in simply copies that data to the location on a load request. When running like this, it never has a problem. When the disk loading routines are in, random crash.

So... first things first, the CIA shell for the protracker replay.

Code:
;------------------------------------------------------------------------------
;
;	$VER: CIA Shell Hardware v1.1 - by Håvard "Howard" Pedersen
;	© 1994-96 Mental Diseases
;
;	A hardware-banging CIA-shell
;
;	I cannot be held responsible for any damage caused directly or in-
;	directly by this code. Still, every released version is thouroughly
;	tested with Mungwall and Enforcer, official Commodore debugging tools.
;	These programs traps writes to unallocated ram and reads/writes to/from
;	non-ram memory areas, which should cover most bugs.
;
;	HISTORY:
;
;v1.0	Simple thingy that worked with ProPruner only. Pretty nasty and thrown
;	together for the musicdisk "Hypnophone" by Compact.
;
;v1.1	Compatibility fix. Rewritten for less label confusion and compatibility
;	with my ProTracker replay.
;
;------------------------------------------------------------------------------
;
;	PUBLIC FUNCTIONS:
;
;Function:	CIA_AddCIAInt(CIASeed, VBR) (D0,A0)
;Purpose:	Attaches our interrupt to the CIAB chip, timer A. CIASeed:
;		PAL = 1773447 and NTSC = 1789773.
;
;Function:	CIA_RemCIAInt()
;Purpose:	Removes our interrupt from the CIAB chip, timer B.
;
;Function:	CIA_IntCode()
;Purpose:	Our CIA interrupt. Only callable from within an CIA interrupt.
;
;Function:	CIA_SetBPM(BPM)(D0.B)
;Purpose:	Adjusts the tempo of the current module.
;
;
;	EXTERNAL FUNCTIONS:
;
;Function:	CIA_CIAInt()
;Purpose:	Does any thingies that are necessary to perform within a CIA
;		interrupt. May trash any register.
;
;------------------------------------------------------------------------------

; Constants. Feel free to change if you know what you're doing.

CIA_CIABase	=	$bfd000
CIA_CIAVector	=	$78

;------------------------------------------------------------------------------
;			C I A _ A D D C I A I N T
;------------------------------------------------------------------------------
CIA_AddCIAInt	move.l	d0,CIA_CIASeed
		move.l	a0,CIA_VBR
		
		move.l	CIA_CIASeed,d0
		divu.w	#125,D0 		; Defaults to 125 BPM

		move.b	d0,CIA_TimerLo
		lsr.w	#8,d0
		move.b	d0,CIA_TimerHi
	
		move.l	CIA_VBR,a0
		move.l	CIA_CIAVector(a0),CIA_OldIntCode
		move.l	#CIA_IntCode,CIA_CIAVector(a0); Set interrupt vector

		lea.l	CIA_CIABase,a0

		move.b	#$7f,$d00(a0)		; Stop all

		move.b	$e00(a0),d0
		and.b	#%11000000,d0
		or.b	#%00001011,d0
		move.b	d0,$e00(a0)

		move.b	CIA_TimerLo,$400(a0)	; Set delay
		move.b	CIA_TimerHi,$500(a0)
		move.b	#$81,$d00(a0)		; Start

		lea.l	$dff000,a6
		move.w	#$a000,$9a(a6)		; Enable CIA interrupt (Level6)

		rts

;------------------------------------------------------------------------------
;			C I A _ R E M C I A I N T
;------------------------------------------------------------------------------
CIA_RemCIAInt	lea.l	$dff000,a6
		move	#$2000,$9a(a6)		; Disable CIA int.

		lea	CIA_CIABase,a0
		move.b	#$7f,$d00(a0)		; Disable CIA clock
		move.b	#%00011000,$e00(a0)

		move.l	CIA_VBR,a0
		move.l	CIA_OldIntCode,CIA_CIAVector(a0); Restore interrupt vector

		rts

;------------------------------------------------------------------------------
;			C I A _ I N T C O D E
;------------------------------------------------------------------------------
CIA_IntCode	movem.l	d0-a6,-(sp)

		lea	CIA_CIABase,a0

		tst.b	$d00(a0)
		move.b	#$7e,$d00(a0)		; Stop some

		move.b	CIA_TimerLo,$400(a0)	; Bestill vekking!
		move.b	CIA_TimerHi,$500(a0)

		move.b	#$81,$d00(a0)		; Start

		move.b	$e00(a0),d0
		and.b	#%11000000,d0
		or.w	#%00001011,d0
		move.b	d0,$e00(a0)		; ...tut & kjør!

		jsr	CIA_CIAInt

; Legg gjerne inn mer her hvis du har lyst...

		move	#$2000,$dff09c
		movem.l	(sp)+,d0-a6
		rte

;------------------------------------------------------------------------------
;			C I A _ S E T B P M
;------------------------------------------------------------------------------
CIA_SetBPM	move.l	d0,-(sp)
		move.l	d1,-(sp)
		move.l	a0,-(sp)
		move.l	CIA_CIASeed,d1
		and.w	#$ff,d0
		lea	CIABPM(pc),a0
		cmp.b	(a0),d0
		beq.s	CIA_SkipBPM
		
		move.b	d0,(a0)
		divu.w	d0,d1

		move.b	d1,CIA_TimerLo
		lsr.w	#8,d1
		move.b	d1,CIA_TimerHi

CIA_SkipBPM	move.l	(sp)+,a0
		move.l	(sp)+,d1
		move.l	(sp)+,d0
		rts

CIABPM		dc.b	$0
		even

;------------------------------------------------------------------------------
;			D A T A
;------------------------------------------------------------------------------
CIA_OldIntCode	dc.l	0
CIA_TimerLo	dc.b	0
CIA_TimerHi	dc.b	0
CIA_CIASeed	dc.l	1773447
CIA_VBR		dc.l	0
Now.. the loader switches...

Code:
; internal constants, don't touch
LD_TIME3MS	= 2148		; 3000/1.3968255
LD_TIME5MS	= 3580		; 5000/1.3968255, 
LD_TIME18MS	= 12886		; 18000/1.3968255, after reversing dir
LD_NODRIVE	= 1		; drive not accessible
LD_READERROR	= 2		; timeout while reading track
LD_OUTOFBOUNDS	= 3		; requested offset/length out of bounds
LD_CRCERROR	= 4		; checksum error

LD_CIAA_A	= 1		; cia a, timer a
LD_CIAA_B	= 2		; cia a, timer b
LD_CIAB_A	= 3		; cia b, timer a
LD_CIAB_B	= 4		; cia b, timer b


; these are the ONLY user changeable settings
LD_USECIA	= LD_CIAA_B	; which timer to use, look above
LD_SAFETY	= 1		; set to 1 for more safety, e.g boundary
				; checking, increases loadersize

LD_CHECKSUM	= 1		; set to 1 to enable checksum check
Do you guys think I might be barking up the wrong tree here or do I have a definite conflict?

I had tried the loader on the other three settings, however the LD_CIAA_B seemed to be the one that worked.

With Revision just round the corner, i'm feeling a bit :
h0ffman is offline  
Old 14 April 2011, 15:33   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,664
Quote:
Originally Posted by h0ffman View Post
Hi Guys
Hi hoffman


Quote:
Originally Posted by h0ffman View Post
I do however have one last bug. Every now and then, the disk loading routine seems to fall over. I very much doubt its bad code as it was written by our one and only Stingray. I think it might be a conflict between the CIA interrupt used for the protracker replay and the CIA timers used in the loader code.
That can be the problem and it's the reason why I made the CIA timers selectable. What exactly happens, does it crash or does it seem to hang in some endless loop?



Quote:
Originally Posted by h0ffman View Post
With Revision just round the corner, i'm feeling a bit :
Still more than a week left, no need to worry yet. Feel free to send me the code [you know the mail addy ] and I'll check/debug.
StingRay is offline  
Old 14 April 2011, 15:48   #3
pmc
gone
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Remember to send me that preview copy when you get this stuff all sorted out h0ffman!

More than a week until official release == too long to wait!
pmc is offline  
Old 14 April 2011, 15:59   #4
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 592
Quote:
That can be the problem and it's the reason why I made the CIA timers selectable. What exactly happens, does it crash or does it seem to hang in some endless loop?
I've seen it do both. Sometimes the disk loading hangs, other times the whole system dies. I suspect the later is caused by a file not loading properly then the decruncher killing the system trying to unpack it.

I'll fire the whole lot over tonight. Disk images, source, data etc. Its a right sod thought cuz i tends to do it near the end of the music disk, which I'm wondering that this is where the CIA BPM timing changes a couple more times. Thankfully I have a right mouse button click which skips the current track! In fact, it's usually when track 10 starts playing which changes the tempo.

In the mean time, i'd better put some focus on writting my pro-tracker entry!?
h0ffman is offline  
Old 14 April 2011, 18:13   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 46
Posts: 25,081
One possible reason: writing to HI timer register immediately starts the timer in oneshot mode (whatever the current timer START bit status)
Toni Wilen is offline  
Old 14 April 2011, 21:01   #6
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 592
Confirmed now! It is for sure when the music changes BPM. Just did another run and track 5 changes from 162 to 163 BPM. As soon as it happens, it screwed over the loading. I think the only reason it is intermittent is it depends on timings.

Now....... how to fix it...

Stingray ?

Email coming through shortly......
h0ffman is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help finding a few games brolly request.Old Rare Games 113 16 June 2015 11:32
Help finding two games! nfmucci request.Old Rare Games 8 07 May 2012 20:09
Need Help Finding A PC Game..... yugioh Looking for a game name ? 1 17 December 2008 10:07
help finding this game Unregistered support.Games 7 16 July 2004 11:18
help finding this game Unregistered support.Games 3 16 July 2004 11:17

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.13991 seconds with 15 queries