Author Topic: Faster fade out code?  (Read 3315 times)

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: Faster fade out code?
« Reply #60 on: December 03, 2016, 11:41:57 AM »
But what I posted was a "safe" version. So that you don't delayed interrupts (in this case, since it's in vblank, the TIRQ routine), through smaller transfers and a small/fast iteration overhead.

Good point!  :wink:

I was trying to keep a similar interface to the original functions which read a single sample, and I was thinking that they'd be run after a vsync() in order to avoid snow on the screen.

But you're right, I should still limit the TAI size in order to avoid blocking the TIMER interrupt.

My bad.  :oops:


Quote
Plus, it's a chance to use the T flag... who doesn't like using the T flag???

Hahaha ... also a good point, but keeping the low-byte of the address in the A reg and doing ...

      adc #$20                          ;2
      sta <low((.loop & 0xff)+2)        ;4

... is a cycle faster, and it avoids messing with my stack-pointer-in-X.

Of course ... I throw away that cycle with the setup and the JSR, but that's a tradeoff for not needing a permanent routine in ZP.

There's certainly an argument for have a few of these Txx-32-byte subroutines in regular RAM to use for self-modifying code, and IIRC, HuC already has one somewhere.  :-k

Here's a corrected code, and of course, things are much cleaner in the CDROM version ...

Code: [Select]
; --------
; Alternate names when the parameter-passing area is used for
; a self-modifying Txx instruction.
;

__tc    = $20F8
__ts    = $20F9
__td    = $20FB
__tl    = $20FD
__tr    = $20FF

; set_colors(int *pbuffer [__ts] )
; set_colors(int index [color_reg], int *pbuffer [__ts], unsigned char count [acc] )
; ----
; index:   index in the palette (0-511)
; pbuffer: source buffer
; count:   # of 16-color palettes, (1-32)
; ----

_set_colors.1:  stz     color_reg_l
                stz     color_reg_h
                lda     #32

_set_colors.3:  tay
.if (!CDROM)
                lda     #$E3 ; TIA
                sta     <__tc
                lda     #$60 ; RTS
                sta     <__tr
                lda     #$04
                sta     <__td+0
                sta     <__td+1
lda     #$20
                sta     <__tl+0
                stz     <__tl+1
                lda     <__ts+0
.l1:            jsr     __tc
                adc     #$20
                sta     <__ts+0
                bcc     .l2
                inc     <__ts+1
.l2:            dey
                bne     .l1
                rts
.else
                lda     <__ts+1
                sta     .l1+2
                lda     <__ts+0
                sta     .l1+1
.l1:            tia     $0000,color_data,$0020
                adc     #$20
                sta     .l1+1
                bcc     .l2
                inc     .l1+2
.l2:            dey
                bne     .l1
                rts
.endif
« Last Edit: December 03, 2016, 11:52:22 AM by elmer »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Faster fade out code?
« Reply #61 on: December 04, 2016, 03:57:39 AM »
Quote
Plus, it's a chance to use the T flag... who doesn't like using the T flag???

Hahaha ... also a good point, but keeping the low-byte of the address in the A reg and doing ...

      adc #$20                          ;2
      sta <low((.loop & 0xff)+2)        ;4

... is a cycle faster, and it avoids messing with my stack-pointer-in-X.

Of course ... I throw away that cycle with the setup and the JSR, but that's a tradeoff for not needing a permanent routine in ZP.
Good catch! My code is actually a little bit longer (I clipped it for the post), as it was meant for a demoscene part where it transfers two 28bytes segments, then sends a sample to the DAC - on large 90k cpu cycle loop. It's one of those dual circular interference patterns things, but translucent like the good ones.

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Faster fade out code?
« Reply #62 on: December 11, 2016, 01:06:03 PM »
Psychic World on the Sega Master System had a pretty smooth and nice-looking fade in & out routine, so I wanted to find out how it did it.  Turns out it was a very simple 3-step process: for fade-outs, ramp down the red channel to zero, then do the same with green and blue sequentially.  Almost a bit too primitive, but it actually looks good in-game.

The SMS has only 3 shades of each colour channel (compared to the 7 per on the PCE) so a fade would have only a total of 4 steps if all 3 channels were simply faded out at the same time.  Doing it sequentially gives 10 steps total.  I'm sure similarly nice effects can be achieved on the PCE.


Above, using the SMS' limited colour space.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Faster fade out code?
« Reply #63 on: December 11, 2016, 03:38:53 PM »
Psychic World on the Sega Master System had a pretty smooth and nice-looking fade in & out routine, so I wanted to find out how it did it.  Turns out it was a very simple 3-step process: for fade-outs, ramp down the red channel to zero, then do the same with green and blue sequentially.  Almost a bit too primitive, but it actually looks good in-game.

I was doing this for Inferno on MSX, but the excessive amount of red in the game made it look pretty stupid, lol.

I ended up just going with a normal fade instead. 
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Faster fade out code?
« Reply #64 on: December 11, 2016, 04:19:35 PM »
Chris, do you have a gif of Sonic's fade out (on the Genesis)?

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Faster fade out code?
« Reply #65 on: December 11, 2016, 05:02:07 PM »
Sorry, no.

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: Faster fade out code?
« Reply #66 on: December 11, 2016, 05:33:31 PM »
Psychic World on the Sega Master System had a pretty smooth and nice-looking fade in & out routine, so I wanted to find out how it did it.  Turns out it was a very simple 3-step process: for fade-outs, ramp down the red channel to zero, then do the same with green and blue sequentially.  Almost a bit too primitive, but it actually looks good in-game.

That's an interesting effect ... thanks for sharing that!  :D

I don't know (yet) if I like if I like it, or not, but it's definitely "effective".

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Faster fade out code?
« Reply #67 on: December 11, 2016, 06:23:53 PM »
Psychic World on the Sega Master System had a pretty smooth and nice-looking fade in & out routine, so I wanted to find out how it did it.  Turns out it was a very simple 3-step process: for fade-outs, ramp down the red channel to zero, then do the same with green and blue sequentially.  Almost a bit too primitive, but it actually looks good in-game.

That's an interesting effect ... thanks for sharing that!  :D

I don't know (yet) if I like if I like it, or not, but it's definitely "effective".


there's alot of interesting fades you can do if you focus on blue-shenanigans, but most people refer to them as coding errors/bugs/not knowing what you're doing.

As opposed to just wanting a weird blue swirly fade that looks cool.

[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Faster fade out code?
« Reply #68 on: December 11, 2016, 07:32:34 PM »
there's alot of interesting fades you can do if you focus on blue-shenanigans, but most people refer to them as coding errors/bugs/not knowing what you're doing.

I beg to differ.  I'd call it Sega's signature style on the Genesis.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Faster fade out code?
« Reply #69 on: December 12, 2016, 04:06:53 AM »
I don't think Arkhan is saying its wrong, just that people perceive it as wrong - for whatever reason they apply (bug/unknowledgeable/etc).

 Check this out:
http://info.sonicretro.org/SCHG_How-to:Improve_the_fade_in%5Cfade_out_progression_routines_in_Sonic_1
Quote
From Sonic Team's point of view, it may not be incorrect and is possibly intentional, however, from a logical point of view, this is incorrect fading

Some people's kids.. I swear.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Faster fade out code?
« Reply #70 on: December 12, 2016, 05:28:49 AM »
Yeah, I mean, what the f*ck is "incorrect" fading, anyways.   Did it make it to the target colors eventually?  Did it look neat?

I find it pretty derpy that people commenting on stuff from the 80s are saying fades that involve color swirlies, or something are wrong.

I mean if it fades and never makes it to where you want, or it causes actual software issues, I'd say that is wrong.

but, fades are inherently lawless.   You can fade whatever to whatever. 

People seem to think the only correct fade is one that fades from black or to black completely in unison.

[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

Gredler

  • Guest
Re: Faster fade out code?
« Reply #71 on: December 12, 2016, 08:47:45 AM »
So you'd say it's a derpy lerpy?

Thank you, I'll be here all week.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Faster fade out code?
« Reply #72 on: December 12, 2016, 09:16:50 AM »
So you'd say it's a derpy lerpy?

Thank you, I'll be here all week.


yes.  exactly, lol.

I did a normalized palette fade (read: correct by codesnobbery standards), and it looked worse than the "wrong fade" that goes to grays first. 

Sometimes "right" can get bent. 
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Faster fade out code?
« Reply #73 on: December 12, 2016, 09:59:17 AM »
Heck, my favourite fade is the Game Over one from NES Ninja Gaiden.  ;-D

edit:
Check this out:
http://info.sonicretro.org/SCHG_How-to:Improve_the_fade_in%5Cfade_out_progression_routines_in_Sonic_1

Holy sperglord-levels of missing-the-point on that page!  The eye is sensitive to the different channels of colour differently, and so Sega was exploiting that, not to mention fading through 8 levels only will look too abrupt and might look like it's "shaking" to some viewers.  :-P
« Last Edit: December 12, 2016, 10:06:55 AM by ccovell »

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Faster fade out code?
« Reply #74 on: December 12, 2016, 04:41:55 PM »
Holy sperglord-levels of missing-the-point on that page!

I loled while eating a cupcake.

Did you know cupcake can come out of your nose?

I do now.

Blue fades are probably one of the most interesting things to dick with, as blue is the most interesting of the 3 colors in terms of our eyes perceiving it.

[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.