NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Triangle's linear counter  
Posted byHugin
Posted on8/5/03 6:15 PM



Disch, after a lot of trouble I finally found a few bugs in my triangle code and after having corrected them, I realized that you were right

all the time - don't change the linear counter mode on $4008 writes. Thanx.
I've used SMB 1 for testing, since I'm very familiar with its music (aren't we all?). After a few changes, it now sounds great. I didn't find

any weird sounds in Mega Man, though.

>- When a write to $400B takes place... the counter goes into load mode (and anything in the load register
>gets loaded into the counter). If $4008.7 was 0, it signals the counter to >enter count mode on the next
>linear counter clock. This is what the NESSOUND doc specifies... >however... in that next linear clock,
>you only go to count mode if $4008.7 is still 0.

This fixed a bug on the lava levels (SMB 1) where some notes were shortened.

>- Changing the mode upon writes to $4008 like the doc specifies seems to cause more problems than it solves.
>When a write to $4008 takes place, don't touch the mode of the linear counter.

This fixed a bug in the flag sequence (SMB 1) where some notes were shortened.

>- if the channel is disabled via $4015, the linear counter shouldn't be loaded with the load
>value even if in load mode. This doesn't seem right, but it seems to work o_O
The channel is always silent when $4015.2 = 1 (Since length counter = 0). The value of the linear counter shouldn't matter. In which game did

you find problems with this?


Below is a brief explanation of my triangle code, with more C-like syntax :)
Perhaps it will be useful to anyone who has followed this thread, or perhaps someone will find a bug and tell me about it.

$4008 write:
LinearCounterLoad = data & 0x7F
if (LinearCounterMode == LOAD)
LinearCounter = LinearCounterLoad

$400A write:
TimerLoad.low = data
Timer = TimerLoad

$400B write:
LengthCounter = LengthCounterTable[data >> 3]
TimerLoad.high = data & 7
Timer = TimerLoad
LinearCounterMode = LOAD
LinearCounter = LinearCounterLoad
ChangeMode = ($4008.7 == 0)

LinearClock:
if (LinearCounterMode == COUNT && LinearCounter)
LinearCounter--

if (ChangeMode)
ChangeMode = 0
if ($4008.7 = 0)
LinearCounterMode = COUNT

LengthClock:
if (LengthCounter && ($4008.7 = 0) && ($4015.2 = 0))
LengthCounter--

TriangleStepGenerator:
Timer = TimerLoad
if (($4015.2 = 0) && LinearCounter && LengthCounter) /* channel enabled? */
if (Output == 0xF) step--
if (Output == 0x0) step++
output += step

Thanx for your help.
/Hugin



-
Entire Thread
Subject  Posted byPosted On
*Triangle's linear counter  Hugin7/24/03 7:02 PM
.*Re: Triangle's linear counter  TimW9/8/03 1:36 PM
..*Re: Triangle's linear counter  Disch9/8/03 3:50 PM
.*Re: Triangle's linear counter  Hugin8/1/03 7:01 PM
..*Re: Triangle's linear counter  Disch8/1/03 8:31 PM
...*Re: Triangle's linear counter  TimW8/6/03 05:26 AM
....*Re: Triangle's linear counter  Disch8/6/03 06:02 AM
....*Re: Triangle's linear counter  TimW8/6/03 05:38 AM
.....*Re: Triangle's linear counter  Disch8/6/03 06:06 AM
...*Re: Triangle's linear counter  Hugin8/1/03 9:21 PM
....*Re: Triangle's linear counter  Disch8/2/03 04:16 AM
.....*Re: Triangle's linear counter  Anonymous8/5/03 8:30 PM
..*Re: Triangle's linear counter  Memblers8/1/03 7:34 PM
...*Re: Triangle's linear counter  Memblers8/1/03 7:40 PM
.*Re: Triangle's linear counter  TimW7/31/03 9:54 PM
..*Re: Triangle's linear counter  Disch7/31/03 10:22 PM
.*Re: Triangle's linear counter  Disch7/26/03 8:28 PM
..*Another Tweak  Disch9/6/03 8:31 PM
...Re: Triangle's linear counter  Hugin8/5/03 6:15 PM
...*Re: Triangle's linear counter  Disch8/5/03 8:45 PM
...*Re: Triangle's linear counter  Hugin8/5/03 6:21 PM
.*Re: Triangle's linear counter  Memblers7/25/03 02:16 AM
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo