simpler way of fading out sound in nintendo out animation + sounds when adding/removing cells
This commit is contained in:
@@ -42,6 +42,14 @@ EditOldBuffer:
|
|||||||
or a, LCDCF_OBJON
|
or a, LCDCF_OBJON
|
||||||
ldh [rLCDC], a
|
ldh [rLCDC], a
|
||||||
|
|
||||||
|
; sound ON
|
||||||
|
ld a, $80
|
||||||
|
ldh [rNR52], a
|
||||||
|
ld a, $77
|
||||||
|
ldh [rNR50], a ; max volume on both speakers
|
||||||
|
ld a, $99
|
||||||
|
ldh [rNR51], a ; channels 1 (pulse) and 4 (noise) on both speakers
|
||||||
|
|
||||||
; init sprite animation
|
; init sprite animation
|
||||||
xor a
|
xor a
|
||||||
ldh [SpriteAnimation], a
|
ldh [SpriteAnimation], a
|
||||||
@@ -207,13 +215,17 @@ EditOldBuffer:
|
|||||||
xor a, %100
|
xor a, %100
|
||||||
ldh [Video + 1], a
|
ldh [Video + 1], a
|
||||||
|
|
||||||
|
; sound OFF
|
||||||
|
xor a
|
||||||
|
ldh [rNR52], a
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
Section "Value to flag", ROM0, ALIGN[8]
|
Section "Value to flag", ROM0, ALIGN[8]
|
||||||
Flag: db 1, 2, 4, 8
|
Flag: db 1, 2, 4, 8
|
||||||
|
|
||||||
; \1: horizontal stride
|
; \1: horizontal stride
|
||||||
ToggleInTargetBuffer: MACRO
|
MoveToCell: MACRO
|
||||||
; move pointer to 2x2 cell group
|
; move pointer to 2x2 cell group
|
||||||
ldh a, [SelectY]
|
ldh a, [SelectY]
|
||||||
sra a
|
sra a
|
||||||
@@ -231,7 +243,9 @@ ToggleInTargetBuffer: MACRO
|
|||||||
sra a
|
sra a
|
||||||
ld e, a
|
ld e, a
|
||||||
add hl, de
|
add hl, de
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
ToggleCell:
|
||||||
; compute cell number in 2x2 cell group
|
; compute cell number in 2x2 cell group
|
||||||
ldh a, [SelectX]
|
ldh a, [SelectX]
|
||||||
and a, 1
|
and a, 1
|
||||||
@@ -241,28 +255,66 @@ ToggleInTargetBuffer: MACRO
|
|||||||
sla a
|
sla a
|
||||||
or a, b
|
or a, b
|
||||||
|
|
||||||
; transform cell number to bit offset in 2x2 cell
|
; transform cell number to bit mask in 2x2 cell
|
||||||
ld d, HIGH(Flag)
|
ld d, HIGH(Flag)
|
||||||
ld e, a
|
ld e, a
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
ld b, a
|
ld b, a
|
||||||
|
|
||||||
ld a, [hl]
|
; go to 2x2 cell in video buffer
|
||||||
xor a, b
|
|
||||||
ld [hl], a
|
|
||||||
ENDM
|
|
||||||
|
|
||||||
ToggleCell:
|
|
||||||
ldh a, [Video]
|
ldh a, [Video]
|
||||||
ld l, a
|
ld l, a
|
||||||
ldh a, [Video + 1]
|
ldh a, [Video + 1]
|
||||||
ld h, a
|
ld h, a
|
||||||
ToggleInTargetBuffer 32
|
MoveToCell 32
|
||||||
|
|
||||||
|
; toggle bit
|
||||||
|
ld a, [hl]
|
||||||
|
xor a, b
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; go to 2x2 cell in automata buffer
|
||||||
ldh a, [Progress]
|
ldh a, [Progress]
|
||||||
ld l, a
|
ld l, a
|
||||||
ldh a, [Old]
|
ldh a, [Old]
|
||||||
ld h, a
|
ld h, a
|
||||||
ToggleInTargetBuffer 20
|
MoveToCell 20
|
||||||
|
|
||||||
|
; toggle bit
|
||||||
|
ld a, [hl]
|
||||||
|
xor a, b
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; do sound based on new value
|
||||||
|
and a, b
|
||||||
|
jr z, .blurp1
|
||||||
|
|
||||||
|
; do noisy sound
|
||||||
|
.blurp0
|
||||||
|
xor a
|
||||||
|
ldh [rNR41], a ; sound length
|
||||||
|
ld a, $F1
|
||||||
|
ldh [rNR42], a ; init volume + envelope sweep
|
||||||
|
ld a, $82
|
||||||
|
ldh [rNR43], a ; frequency
|
||||||
|
ld a, $80
|
||||||
|
ldh [rNR44], a ; start
|
||||||
|
jr .exit
|
||||||
|
|
||||||
|
; do pulsy sound
|
||||||
|
.blurp1
|
||||||
|
xor a
|
||||||
|
ldh [rNR10], a ; sweep
|
||||||
|
ld a, (%01 << 6) + 30
|
||||||
|
ldh [rNR11], a ; pattern + sound length
|
||||||
|
ld a, $43
|
||||||
|
ldh [rNR12], a ; init volume + envelope sweep
|
||||||
|
ld a, $D7
|
||||||
|
ldh [rNR13], a ; frequency low ($6D7 = 1751 => 440Hz)
|
||||||
|
ld a, $83
|
||||||
|
ldh [rNR14], a ; start + frequency high
|
||||||
|
|
||||||
|
.exit
|
||||||
ret
|
ret
|
||||||
|
|
||||||
Clear:
|
Clear:
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ ScrollNintendoOut:
|
|||||||
|
|
||||||
; sound ON
|
; sound ON
|
||||||
ld a, $80
|
ld a, $80
|
||||||
ldh [rNR52], a ; sound ON with noise channel
|
ldh [rNR52], a
|
||||||
ld a, $77
|
ld a, $77
|
||||||
ldh [rNR50], a ; max volume on both speakers
|
ldh [rNR50], a ; max volume on both speakers
|
||||||
ld a, $88
|
ld a, $88
|
||||||
ldh [rNR51], a ; noise channel on both speakers
|
ldh [rNR51], a ; noise channel on both speakers
|
||||||
|
|
||||||
; make noise
|
; make noise
|
||||||
ld a, 0
|
xor a
|
||||||
ldh [rNR41], a ; set sound duration
|
ldh [rNR41], a ; set sound duration
|
||||||
ld a, $F0
|
ld a, $F0
|
||||||
ldh [rNR42], a ; set volume
|
ldh [rNR42], a ; set volume
|
||||||
@@ -74,36 +74,24 @@ ScrollNintendoOut:
|
|||||||
ldh [rSCY], a
|
ldh [rSCY], a
|
||||||
|
|
||||||
; change noise
|
; change noise
|
||||||
|
xor a
|
||||||
|
ldh [rNR41], a ; set sound duration
|
||||||
|
ld a, $F4
|
||||||
|
ldh [rNR42], a ; set volume with long sweep
|
||||||
ld a, $62
|
ld a, $62
|
||||||
ldh [rNR43], a ; set frequency
|
ldh [rNR43], a ; set frequency
|
||||||
|
ld a, $80
|
||||||
ld b, 4 ; number of frames before reducing volume
|
ldh [rNR44], a ; start
|
||||||
ld c, 16 ; number of steps before volume is 0
|
|
||||||
|
|
||||||
; nintendo logo lift-off!
|
; nintendo logo lift-off!
|
||||||
.scrollup
|
.scrollup
|
||||||
HaltAndClearIF
|
HaltAndClearIF
|
||||||
|
|
||||||
; scroll up
|
; scroll up
|
||||||
ldh a, [rSCY]
|
ldh a, [rSCY]
|
||||||
inc a
|
inc a
|
||||||
ldh [rSCY], a
|
ldh [rSCY], a
|
||||||
|
|
||||||
; fade out
|
|
||||||
ld a, c
|
|
||||||
or a
|
|
||||||
jr z, .novolumechange
|
|
||||||
dec b
|
|
||||||
jr nz, .novolumechange
|
|
||||||
; decrement volume by 1
|
|
||||||
; see http://gbdev.gg8.se/wiki/articles/Gameboy_sound_hardware obscure behavior...
|
|
||||||
ld a, $08
|
|
||||||
REPT 15
|
|
||||||
ldh [rNR42], a
|
|
||||||
ENDR
|
|
||||||
ld b, 4
|
|
||||||
dec c
|
|
||||||
|
|
||||||
.novolumechange
|
|
||||||
; loop until nintendo logo is out of screen
|
; loop until nintendo logo is out of screen
|
||||||
ldh a, [rSCY]
|
ldh a, [rSCY]
|
||||||
cp a, 88
|
cp a, 88
|
||||||
|
|||||||
Reference in New Issue
Block a user