Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,491,146
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-27-24 04:51 AM
Guest: Register | Login

0 users currently in ROM Hacking | 2 guests

Main - ROM Hacking - Can I have some preset HDMA tables? New thread | New reply


cory21391
Posted on 08-08-07 06:00 PM Link | Quote | ID: 61052


Flurry
Level: 37

Posts: 72/260
EXP: 331887
Next: 6366

Since: 03-01-07
From: NC, US

Last post: 5129 days
Last view: 5129 days
yeah, I got HDMA now, but.... Well, I suck at animations and suck even more at wavey animations. So, are there any preset (3 or 4) hdma tables to simulate H-Scroll waviness? (kinda like DCK water levels) I tried to use 3 tables and after every so many wai's I'd change the table (the order was 1, 2, 3, 2, 1 ....etc.) but it was quite horrible

____________________




blackhole89
Posted on 08-08-07 06:10 PM Link | Quote | ID: 61056


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 388/4196
EXP: 21534225
Next: 302376

Since: 02-19-07
From: Ithaca, NY, US

Last post: 472 days
Last view: 85 days



If you want the background to be animated, preset tables won't work by definition. What you, however, can do the following:
- Make a simple sine table for one period in ROM, going from like -5 to +5 in terms of amplitude and stretched out on whatever you want the wave length to be. Powers of 2 would make the math to do in the following easier.
- Create a counter that is incremented every frame and wraps around to zero after it hits the number of entries in the sine table.
- Have a subroutine generate an HDMA table in RAM that does as follows:
- 2 bytes write twice to register 210F (BG2 hscroll)
- fill it with entries like:
[$02 or whatever you want the number of scanlines for a "step" of the wave]
[2 bytes: base BG2 scroll + the entry of the sine table at [(entry#+counter) mod sine table length]
- make it be used as described

While I don't have the tools at hand to test it out and no time to write it out as code, it should work roughly as that.

____________________



cory21391
Posted on 08-08-07 06:20 PM Link | Quote | ID: 61059


Flurry
Level: 37

Posts: 73/260
EXP: 331887
Next: 6366

Since: 03-01-07
From: NC, US

Last post: 5129 days
Last view: 5129 days
Couldn't i just use preset hdma tables as "frames" and wai so many times and change the table on the channel and loop it? I actually did this, but my values for BG2 scroll sucked and it just like moved back and forth...

an example would be:

hdmaloop:
jsr hdma1
jsr hdma2
jsr hdma3
jsr hdma2
jmp hdmaloop

hdma1:
stz $420C
lda #%00000010
sta $4300 ;HDMA transfer settings
lda #$0F
sta $4301 ;sets destination to $0F, BG2 H-Scroll
ldx #hdmatable0
stx $4302 ;sets source offset
lda #:hdmatable0
sta $4304 ;sets source bank

lda #$01
sta $420C ;enables HDMA transfer through channel 0
jsr wailoop ;wai's so many frames
rts

hdma2:
stz $420C
lda #%00000010
sta $4300 ;HDMA transfer settings
lda #$0F
sta $4301 ;sets destination to $0F, BG2 H-Scroll
ldx #hdmatable1
stx $4302 ;sets source offset
lda #:hdmatable1
sta $4304 ;sets source bank
lda #$01
sta $420C ;enables HDMA transfer through channel 0
jsr wailoop ;wai's so many frames
rts

hdma 3:
stz $420C
lda #%00000010
sta $4300 ;HDMA transfer settings
lda #$0F
sta $4301 ;sets destination to $0F, BG2 H-Scroll
ldx #hdmatable2
stx $4302 ;sets source offset
lda #:hdmatable2
sta $4304 ;sets source bank
lda #$01
sta $420C ;enables HDMA transfer through channel 0
jsr wailoop ;wai's so many frames
rts



____________________




blackhole89
Posted on 08-08-07 08:55 PM Link | Quote | ID: 61100


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 389/4196
EXP: 21534225
Next: 302376

Since: 02-19-07
From: Ithaca, NY, US

Last post: 472 days
Last view: 85 days



You could do that, only it would use up an unnecessarily high amount of memory unless you went for a really low-resolution effect and wouldn't work if the background had some scroll of its own...

Also, unless the wavy BG is the only thing your ROM is going to do, what you wrote there could be considered very bad style at best... you should implement that kind of code into some kind of main loop/NMI routine instead.

____________________



cory21391
Posted on 08-08-07 09:05 PM Link | Quote | ID: 61113


Flurry
Level: 37

Posts: 75/260
EXP: 331887
Next: 6366

Since: 03-01-07
From: NC, US

Last post: 5129 days
Last view: 5129 days
yeah, I could optimize this and put the table's address in RAM, and just change the source address in vblank or something... But, uh, I don't really understand all of your suggestive code. I may sound stupid for asking this, but "what's a sine table?" the only place I've heard sine is somewhere in Alg 2 but I wasn't paying attention

____________________




MathOnNapkins
Posted on 08-08-07 09:47 PM Link | Quote | ID: 61135


Super Koopa
Level: 62

Posts: 193/842
EXP: 1935624
Next: 49062

Since: 02-19-07
From: durff

Last post: 4489 days
Last view: 4012 days
Sine just means it looks like a nice smooth wave (rather than a jagged wave). You want animation to look smooth, not stilted.

And I guess you figured out that HDMA effects aren't automatically awesome unless you put some work into them.

____________________
Zelda Hacking Forum
hobbies: delectatio morosa

blackhole89
Posted on 08-08-07 10:10 PM (rev. 2 of 08-08-07 10:25 PM) Link | Quote | ID: 61142


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 390/4196
EXP: 21534225
Next: 302376

Since: 02-19-07
From: Ithaca, NY, US

Last post: 472 days
Last view: 85 days






The blue one is a sine wave. Wikilink is go
Trigonometric functions are something you always should know, especially when messing with computer graphics

____________________



cory21391
Posted on 08-09-07 05:29 PM Link | Quote | ID: 61424


Flurry
Level: 37

Posts: 77/260
EXP: 331887
Next: 6366

Since: 03-01-07
From: NC, US

Last post: 5129 days
Last view: 5129 days

And I guess you figured out that HDMA effects aren't automatically awesome unless you put some work into them.

lol yeah, at first I was actually stupid enough to think that if I copied the BG2 wavey scroll table from qwertie's GFX doc it would simulate waves.... AHAHAHA!!! yeah.... I feel dumb now

But anyways, I think I know how to sort this out now. It'll take some work, but then again, so will programmnig an entire game...

thanks again for the help

____________________




Ailure
Posted on 08-11-07 03:43 PM Link | Quote | ID: 61843

Hats
Steam Board2 group
Level: 121

Posts: 1430/3965
EXP: 19780291
Next: 276405

Since: 02-19-07
From: Sweden, Skåne

Last post: 3302 days
Last view: 2053 days
Posted by blackhole89
Trigonometric functions are something you always should know, especially when messing with computer graphics
Indeed. I realized this for a month ago when I was making a quick clock in openGL. I had to read a bit in Wikipedia to get it going, since it's been ages since I learned Trigonometry.

____________________
AIM: gamefreak1337, MSN: Emil_sim@spray.se, XMPP: ailure@xmpp.kafuka.org


smkdan
Posted on 08-12-07 02:28 PM Link | Quote | ID: 61970


Ninji
Level: 36

Posts: 72/238
EXP: 288666
Next: 19444

Since: 05-26-07

Last post: 4063 days
Last view: 4012 days
In WLA, .DBSIN and .DWSIN let you create tables very easily. You enter the starting angle, number of entries, rate of oscilliation, amplitude, and an optional additive. It'll conveniently create a bunch of signed numbers from it.

cory21391
Posted on 08-13-07 05:42 PM Link | Quote | ID: 62164


Flurry
Level: 37

Posts: 82/260
EXP: 331887
Next: 6366

Since: 03-01-07
From: NC, US

Last post: 5129 days
Last view: 5129 days
well, as far as Trigonometric functions go, I'm about to be in 11th grade, so this year I'll be taking pre-calc. so yeah...

____________________




Main - ROM Hacking - Can I have some preset HDMA tables? New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.024 seconds. (341KB of memory used)
MySQL - queries: 67, rows: 97/98, time: 0.016 seconds.