It is currently Fri Nov 24, 2017 10:57 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 106 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8  Next
Author Message
PostPosted: Wed May 06, 2015 12:49 am 
Offline
User avatar

Joined: Sun Oct 12, 2014 11:06 am
Posts: 123
Location: Finland
I made a list of sound engine variables that I need to use. Tell me if there are some important ones missing, considering the data type I'm using:

The variables with 'env' are used to keep track of the offset in the envelope stream.

Code:
sound_disable_flag .rs 1
current_song .rs 1
current_channel .rs 1
sq1_pattern .rs 1
sq1_stream .rs 1
sq1_vol .rs 1
sq1_vol_env .rs 1
sq1_pitch_env .rs 1
sq1_note_lo .rs 1
sq1_note_hi .rs 1
sq1_len_lo .rs 1
sq1_len_hi .rs 1
sq1_inst .rs 1
sq2_pattern .rs 1
sq2_stream .rs 1
sq2_vol .rs 1
sq2_vol_env .rs 1
sq2_pitch_env .rs 1
sq2_note_lo .rs 1
sq2_note_hi .rs 1
sq2_len_lo .rs 1
sq2_len_hi .rs 1
sq2_inst .rs 1
tri_pattern .rs 1
tri_stream .rs 1
tri_note_lo .rs 1
tri_note_hi .rs 1
tri_len_lo .rs 1
tri_len_hi .rs 1
noise_pattern .rs 1
noise_stream .rs 1
noise_note .rs 1
noise_len_lo .rs 1
noise_len_hi .rs 1
dmc_pattern .rs 1
dmc_stream .rs 1
dmc_sample .rs 1
dmc_len_lo .rs 1
dmc_len_hi .rs 1


Here is a short compilation of the current structure of the data format:

Code:
; Music Data

            ; Channels in track

MusicBoss:
 .dw BossSQ1,BossSQ2,BossTri,BossNoise,BossDMC

            ; Patterns in channel

BossSQ1:
 .dw BossSQ1_00,BossSQ1_00
 .dw BossSQ1_01,BossSQ1_02,BossSQ1_03,BossSQ1_04
 .dw BossSQ1_01,BossSQ1_02,BossSQ1_03,BossSQ1_04
 .dw BossSQ1_05,BossSQ1_06,BossSQ1_05,BossSQ1_07

BossDMC:
 .dw BossDMC_00,BossDMC_01
 .dw BossDMC_02,BossDMC_02,BossDMC_02,BossDMC_02
 .dw BossDMC_02,BossDMC_02,BossDMC_02,BossDMC_03
 .dw BossDMC_02,BossDMC_02,BossDMC_02,BossDMC_04

            ; Streams in Pattern

BossSQ1_00:
 .dw BossSQ1_00_Note,BossSQ1_00_Inst
 .dw BossSQ1_00_Len_Lo,BossSQ1_00_Len_Hi

BossDMC_00:
 .dw BossDMC_00_Sample,BossDMC_00_Lo,BossDMC_00_Hi

Code:
; Stream Data

            ; Square 1

BossSQ1_00_Note:
 .db B_2,As2,A_2,Gs2
 .db B_2,As2,A_2,Gs2
 .db B_2,As2,A_2,Gs2
 .db B_2,As2,A_2,Gs2

BossSQ1_00_Inst:
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0

BossSQ1_00_Len_Lo:
 .db $06,$07,$06,$07
 .db $06,$07,$06,$07
 .db $06,$07,$06,$07
 .db $06,$07,$06,$07

BossSQ1_00_Len_Hi:
 .db $00,$00,$00,$00
 .db $00,$00,$00,$00
 .db $00,$00,$00,$00
 .db $00,$00,$00,$00

            ; DMC

BossDMC_00_Sample:
 .db Kick,Kick,Kick,Kick

BossDMC_00_Len_Lo:
 .db $1A,$1A,$1A,$1A

BossDMC_00_Len_Hi:
 .db $00,$00,$00,$00


Code:
; Instrument Data

SQInstrumentNull:
 .db SQ_Duty0,NoEnv,NoEnv

SQInstrument0:
 .db SQ_Duty1,SQVolEnv0,SQPtcEnv0

SQInstrument1:
 .db SQ_Duty1,SQVolEnv2,SQPtcEnv0

SQInstrument2:
 .db SQ_Duty1,SQVolEnv2,SQPtcEnv1

SQInstrument3:
 .db SQ_Duty1,SQVolEnv2,SQPtcEnv2

SQInstrument4:
 .db SQ_Duty1,SQVolEnv4,SQPtcEnv0

SQInstrument5:
 .db SQ_Duty1,SQVolEnv1,SQPtcEnv0

SQInstrument6:
 .db SQ_Duty2,SQVolEnv3,NoEnv

SQInstrument7:
 .db SQ_Duty2,SQVolEnv5,SQPtcEnv0

SQInstrument8:
 .db SQ_Duty0,SQVolEnv6,SQPtcEnv0


SQ_Duty0:
 .db %00110000         ; Duty 12.5%, Length Counter Halt, Constant Volume

SQ_Duty1:
 .db %01110000         ; Duty 25%, Length Counter Halt, Constant Volume

SQ_Duty2:
 .db %10110000         ; Duty 50%, Length Counter Halt, Constant Volume

SQ_Duty3:
 .db %11110000         ; Duty 75%, Length Counter Halt, Constant Volume

Noise_0:
 .db %00110000

Noise_Duty0:
 .db %00000000

Noise_Duty1:
 .db %10000000

 ; %xxx1 xxxx 0 = Add, 1 = Subtract (Pitch only) ($10)
 ; %xx1x LLLL Loop Flag, Subtract 'LLLL' from envelope stream counter  ($2L)
 ; %x1xx WWWW Wait 'WWWW' frames and move on to the next byte ($4W)
 ; %1xxx xxxx Halt Flag, Stop envelope update and leave last updated value ($80)

NoEnv:
 .db $80

            ; Square Volume Envelopes

SQVolEnv00:
 .db $07,$07,$07,$06,$06,$05,$80

SQVolEnv01:
 .db $02,$02,$02,$01,$80

SQVolEnv02:
 .db $06,$06,$07,$80

SQVolEnv03:
 .db $02,$02,$02,$00,$00,$01,$80

SQVolEnv04:
 .db $06,$06,$07,$01,$80

SQVolEnv05:
 .db $04,$04,$03,$01,$80

SQVolEnv06:
 .db $02,$02,$03,$01,$80

            ; Noise Volume Envelopes

NoiseVolEnv00:
 .db $05,$05,$03,$03,$01,$00,$80

NoiseVolEnv01:
 .db $03,$03,$02,$02,$01,$00,$80

            ; Square Pitch Envelopes

SQPtcEnv00:
 .db $43,$14,$00,$07,$00,$17,$00,$24

SQPtcEnv01:
 .db $46,$14,$00,$00,$07,$00,$00,$00,$17,$00,$00,$27

SQPtcEnv02:
 .db $4F,$4B,$14,$00,$00,$07,$00,$00,$00,$17,$00,$00,$27


Code:
; Note Effects

         ; Effects (Bit 7 indicates effect if it's set)

OctUp = $C0      ; %1100 0000
OctDwn = $A0      ; %1010 0000
Loop = $90      ; %1001 0000
Stop = $80      ; %1000 0000


Code:
; DMC Data

Kick = $00      ; DMC offsets
SnareLo = $01
SnareHi = $02
TomLo = $03
TomMed = $04
TomHi = $05

DMC_Pitch:
 .db $0E,$0C,$0D,$0C,$0D,$0E

DMC_Address:
 .db $FD,$FE,$FE,$FF,$FF,$FF

DMC_Length:
 .db $08,$30,$30,$20,$20,$20


Code:
; DMC Addresses

 .bank 3
 .org $FF40
 .incbin "KickLen$08.dmc"

 .org $FF80
 .incbin "SnareLen$30.dmc"

 .org $FFC0
 .incbin "TomLen$20.dmc"


The post ended up begin pretty long, even though I only put in about 10% of the music data

_________________
UP SIDE DOWN A B A B B A B A Hidari migi
L R L R STOP & DASH & UP & TALK Ijou nashi


Top
 Profile  
 
PostPosted: Wed May 06, 2015 10:53 pm 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 138
Location: Hungary
Code:
BossSQ1_00_Inst:
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0
 .db SQInstrument0,SQInstrument0,SQInstrument0,SQInstrument0

BossSQ1_00_Len_Lo:
 .db $06,$07,$06,$07
 .db $06,$07,$06,$07
 .db $06,$07,$06,$07
 .db $06,$07,$06,$07

BossSQ1_00_Len_Hi:
 .db $00,$00,$00,$00
 .db $00,$00,$00,$00
 .db $00,$00,$00,$00
 .db $00,$00,$00,$00


This is the part that's probably going to cause you a huge space issue over time. I have implemented a "popular" note format for myself and I can't begin to tell you how much space it saves in comparison. It pretty much merges the Len_Lo Len_Hi and Note data into a single byte.
Now my version is not the most versatile out there because it doesn't support alternating speeds like you would do it with Fxx Fxx±1 Fxx Fxx±1 in Famitracker. You have to introduce a speed variable and octave variables for the 3 tonal channels for it. The data format looks like this:
LLLN NNNN - where L is your note length (but L = 0 is reserved for meaning note effects) and N is the positive deviation from the current octave of the channel. So if say, N = %00010 and your octave is set to $03 then it's going to find the 3x12 +2 note ID. This limits you to be able to access 2 and a half octaves at a time, but you can also program a single-byte effect to add or decrease octave by 2 to make it even more effective. When you are calculating the note ID, you can also add transposition values or arpeggio values to find what you really after at that time.
My engine does this: Octave×12 + N + Arpeggio + Channel transposition + Global transposition = Note ID

And I calculate length in frames simply by taking the speed value and shifting it left L-1 times. It evaluates to powers of two-number of rows in Famitracker basically.


Top
 Profile  
 
PostPosted: Wed May 06, 2015 11:31 pm 
Offline
User avatar

Joined: Sun Oct 12, 2014 11:06 am
Posts: 123
Location: Finland
Instead of giving every note instrument value separately, I could make a it so that the instrument table only has the changes in the instruments and how many notes that instrument plays before changing to the next one.

This would be all for SQ1 in the boss theme I have already made.
Code:
BossSQ1InstTable:
 .db SQInstrument0
 .db SQInstrument1,SQInstrument2,SQInstrument3
 .db SQInstrument1,SQInstrument2,SQInstrument3
 .db SQInstrument4

BossSQ1InstLen:
 .db $10
 .db $02,$05,$01
 .db $02,$05,$01
 .db $40


I also could leave len_hi out and make a tied note effect. I didn't use len_hi in the boss theme at all, so It's just a bunch of $00 in there for no reason. The tied note effect would tell the sound engine to read next len_lo byte without updating anything else extending the duration of the note. I probably won't use len_hi a lot so this would also save a lot of space.

_________________
UP SIDE DOWN A B A B B A B A Hidari migi
L R L R STOP & DASH & UP & TALK Ijou nashi


Top
 Profile  
 
PostPosted: Thu May 07, 2015 5:25 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19259
Location: NE Indiana, USA (NTSC)
za909 wrote:
I have implemented a "popular" note format for myself and I can't begin to tell you how much space it saves in comparison. It pretty much merges the Len_Lo Len_Hi and Note data into a single byte.
[...]
You have to introduce a speed variable and octave variables for the 3 tonal channels for it. The data format looks like this:
LLLN NNNN - where L is your note length (but L = 0 is reserved for meaning note effects) and N is the positive deviation from the current octave of the channel.

I do essentially the same thing in my own engine, except I roll the "current octave" into channel transposition, and I reserve N=27-31 for effects so that I can look up L from the table [1, 2, 3, 4, 6, 8, 12, 16] so that I get values between powers of two that commonly occur with dotted notes and the swung time that appears in a lot of my music. Then N=25 is tie (with L being additional length), N=26 is note cut (with L being length of rest), and N=0 to 24 are offsets from the channel transposition (which can be changed with transpose effects).


Top
 Profile  
 
PostPosted: Fri Jun 26, 2015 11:04 am 
Offline
User avatar

Joined: Sun Oct 12, 2014 11:06 am
Posts: 123
Location: Finland
I just recently got back to this project!
I tried to continue the sound engine, but I can't figure out a good way to run it (which is probably why I have not continued it). I need to get some addresses setup when a song or SFX is requested, and then run the engine itself in such way that I can use the patterns and instruments. I'm pretty sure I posted the sound format on this topic already. That might be useful. Also, any changes to the sound format that would make running it easier are welcome too.

Then the other stuff!
I made some updates to the graphics (background made in YY-CHR and sprites added afterwards in paint):
The top will be parallax scrolled by the way
Image

I also had an idea where the boss of the stage that takes place in a forest sets the forest on fire on it's appearance. The fire will be using the same wavy effect that I used in the title screen. Though, I may need to scrap the idea if it creates too much slowdown, but well see when I get there.

_________________
UP SIDE DOWN A B A B B A B A Hidari migi
L R L R STOP & DASH & UP & TALK Ijou nashi


Top
 Profile  
 
PostPosted: Tue Jul 14, 2015 10:02 am 
Offline
User avatar

Joined: Sun Oct 12, 2014 11:06 am
Posts: 123
Location: Finland
Completely remade the player sprites. Instead of using edited Castlevania II Werewolf sprites, I only used them as a reference when I felt like I couldn't make some part look right. IMO, these look better for begin the player as the sprites are in a more upright posture than the enemy Werewolf in CV II.

Attachment:
KemonoPlayerSpr.png
KemonoPlayerSpr.png [ 3.61 KiB | Viewed 2049 times ]

_________________
UP SIDE DOWN A B A B B A B A Hidari migi
L R L R STOP & DASH & UP & TALK Ijou nashi


Top
 Profile  
 
PostPosted: Mon Dec 14, 2015 5:17 am 
Offline
User avatar

Joined: Sun Oct 12, 2014 11:06 am
Posts: 123
Location: Finland
After a long break, I came back to this project. I managed to get the sprite assembler one step closer begin fully functional. The sprite appears on screen, however, there are some odd things I can't figure out:
1. The sprite "breaks" when scrolled off screen
2. Flip masks don't work correctly (?), $06D0 = h_flip and $06E0 = v_flip
3. Sprite no. 1 is displayed regardless of object sprite begin set to #$00 instead of #$01 ($0690 in memory)
4. obj_sprite_count has no changes in ram search (used to define how many 8x8 sprites to process for the metasprite)

The .nes file is attached, so people can take a look at the problem. I also attacked the .asm file that contains all the variables to make debugging easier. If there are any problems understanding where a specific variable is used, feel free to ask c:


Attachments:
Variables&Registers.asm [3.07 KiB]
Downloaded 70 times
Kemono.nes [24.02 KiB]
Downloaded 89 times

_________________
UP SIDE DOWN A B A B B A B A Hidari migi
L R L R STOP & DASH & UP & TALK Ijou nashi
Top
 Profile  
 
PostPosted: Sun Dec 20, 2015 4:00 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3484
Location: Indianapolis
I haven't completely followed the previous pages of the thread, so hopefully I didn't miss some important background info.

But just from a quick view of the OAM memory, it looks like you're doing some kind of OAM cycling when the character is on the screen. When you scroll it off the screen, this OAM cycling totally breaks down. The character's sprites stay at the last OAM position used, and the X positions of all 64 sprites seem to gradually settle into a value that depends on the scroll position.

(edit: just noticed my reply is a week late, hope this little observation helps anyways)


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 5:02 pm 
Offline
User avatar

Joined: Sat Jul 12, 2014 3:04 pm
Posts: 950
Tsutarja wrote:
I also had an idea where the boss of the stage that takes place in a forest sets the forest on fire on it's appearance. The fire will be using the same wavy effect that I used in the title screen. Though, I may need to scrap the idea if it creates too much slowdown, but well see when I get there.

Like in Sonic 3 & Knuckles, Demon's Crest, or some others? (hmm, did the boss in Tails' Adventure do it?)


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 6:29 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10119
Location: Rio de Janeiro - Brazil
Myask wrote:
Like in Sonic 3 & Knuckles, Demon's Crest, or some others? (hmm, did the boss in Tails' Adventure do it?)

None of those games are on the NES though, so there's still merit in this idea. :D


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 6:37 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3119
Location: Nacogdoches, Texas
Well, now that Myask mentioned forests fires, I imagine a wavy effect you described would take up pretty much all the CPU time if you weren't using a mapper to change scrolling, because I think it has to be timed otherwise like mid scanline scrolling on the SNES. I really don't know much about the NES, but wouldn't it be possible to change out chrrom graphics for the BG every couple of frames to actually animate the fire without a special mapper?

tokumaru wrote:
Myask wrote:
Like in Sonic 3 & Knuckles, Demon's Crest, or some others? (hmm, did the boss in Tails' Adventure do it?)

None of those games are on the NES though, so there's still merit in this idea. :D

Yet another 16bit forest fire:

Image


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 6:54 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10119
Location: Rio de Janeiro - Brazil
Espozo wrote:
Well, now that Myask mentioned forests fires, I imagine a wavy effect you described would take up pretty much all the CPU time if you weren't using a mapper to change scrolling

Yes, without mapper IRQs the CPU will be pretty busy. Ideally you'd place the effect near the top of the screen , so you still had a good portion of the time left for the game logic.

Quote:
wouldn't it be possible to change out chrrom graphics for the BG every couple of frames to actually animate the fire without a special mapper?

Well.. you need a special mapper for changing CHR-ROM anyway, so...

Games avoiding fancy raster effects would most likely do large fires by cycling the palette, which conveys the idea but doesn't look so cool.

Quote:
Yet another 16bit forest fire:

I'm sure there are plenty of examples, this idea isn't exactly the most original idea ever. Characters jumping around in blocky worlds have also been done to death, but we're still doing that, aren't we? :wink:


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 7:04 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1835
Location: DIGDUG
What about DMC music channel IRQs?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 7:05 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3119
Location: Nacogdoches, Texas
tokumaru wrote:
Games avoiding fancy raster effects would most likely do large fires by cycling the palette, which conveys the idea but doesn't look so cool.

That's actually what's done in the example I showed.

tokumaru wrote:
Well.. you need a special mapper for changing CHR-ROM anyway, so...

Doesn't just about any NES game past 1987 change CHR-ROM for different level graphics and stuff like that? What would require a more advanced mapper, swapping out the graphics, or doing row scrolling?


Top
 Profile  
 
PostPosted: Wed Dec 23, 2015 7:15 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10119
Location: Rio de Janeiro - Brazil
Espozo wrote:
Doesn't just about any NES game past 1987 change CHR-ROM for different level graphics and stuff like that?

Most mappers with fine CHR-ROM swapping (finer than 4KB) have IRQs too, so there really isn't much to choose in terms of mappers.

Quote:
What would require a more advanced mapper, swapping out the graphics, or doing row scrolling?

Swapping graphics in small chunks would require an advanced mapper, while row scrolling can be done with no mapper if you're willing to dedicate the CPU time necessary. If not, you need IRQs, which are only available in advanced mappers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 106 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: bazza and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group