;Makes fadeouts/fadeins custom by using windowing HDMA
;Version 1.1
HEADER
LOROM
!FreeRAM = $13C0 ;must be abs
!FreeSpace = $66823E
ORG $00C9EB ;NEW: Fix overworld mosaic screwup after you finish bonus level 000/100
BRA +
NOP #3
+
ORG $00A0A3
BRA +
NOP #3
+
ORG $009F37
JML MainFades
HijackReturn: RTS
ORG !FreeSpace
reset bytes
db "STAR"
dw End-Begin-$01
dw End-Begin-$01^$FFFF
Begin:
MainFades: LDA $1EEB
CMP #$83
BNE Start
LDX $010B
LDA Table,x
STA $0DAE
BRA Normal
Start: LDA #$0F
STA $0DAE
Normal: INC !FreeRAM
LDA #$22
STA $41
STA $42
STA $43 ;setup HDMA properties
LDA #$20
TSB $44
LDA #$10
TRB $44
LDA !FreeRAM ;following wall of code sets up animated HDMA table algorithm-wise
LDY $0DAF
BNE +
EOR #$FF
+ ASL A
ASL A
ASL A
LDX #$0E
- STZ $04A0,x
STZ $04C0,x
STZ $04E0,x
STZ $0500,x
STZ $0520,x
STZ $0540,x
STZ $0560,x
STZ $0580,x
STZ $05A0,x
STZ $05C0,x
STZ $05E0,x
STZ $0600,x
STZ $0620,x
STZ $0640,x
INC A
CPX #$07
BCS +
DEC A
DEC A
+ STA $04A1,x
STA $04C1,x
STA $04E1,x
STA $0501,x
STA $0521,x
STA $0541,x
STA $0561,x
STA $0581,x
STA $05A1,x
STA $05C1,x
STA $05E1,x
STA $0601,x
STA $0621,x
STA $0641,x
REP 2 : DEX
BPL -
EOR #$FF
LDX #$0E
- DEC A
CPX #$07
BCS +
INC A
INC A
+ STA $04B0,x
STA $04D0,x
STA $04F0,x
STA $0510,x
STA $0530,x
STA $0550,x
STA $0570,x
STA $0590,x
STA $05B0,x
STA $05D0,x
STA $05F0,x
STA $0610,x
STA $0630,x
STA $0650,x
PHA
LDA #$FF
STA $04B1,x
STA $04D1,x
STA $04F1,x
STA $0511,x
STA $0531,x
STA $0551,x
STA $0571,x
STA $0591,x
STA $05B1,x
STA $05D1,x
STA $05F1,x
STA $0611,x
STA $0631,x
STA $0651,x
PLA
REP 2 : DEX
BPL - ;end of HDMA table setup code
LDA #$41 ;\
STA $4370 ; |
LDA #$26 ; |
STA $4371 ; |Enable HDMA
LDA.b #IndirectPtrs ; |
STA $4372 ; |
LDA.b #IndirectPtrs>>8 ; |
STA $4373 ; |
LDA.b #IndirectPtrs>>16 ; |
STA $4374 ; |
STZ $4377 ; |
LDA #$80 ; |HDMA enable
TSB $0D9F ;/
LDA !FreeRAM
CMP #31
BNE +
LDA $0DAF
BNE ++
REP #$10
LDX #$01BE
LDA #$FF
- STA $04A0,x ;clear HDMA table when done
STZ $04A1,x
DEX
DEX
BPL -
SEP #$10
++ STZ !FreeRAM
STZ $41
STZ $42 ;sets HDMA properties back to normal
STZ $43
LDA #$02
STA $44
LDA $0DAF ;Fading direction. $00 = Fadein, $01 = Fadeout
EOR #$01 ;reverse fading direction.
STA $0DAF
INC $0100 ;Gamemode++;
LDA #$80 ;HDMA clear
TRB $0D9F
+ JML HijackReturn
IndirectPtrs: db $F0 : dw $04A0 ;Ptrs for indirect hdma
db $F0 : dw $0580
db $00
Table:
db $0F,$04,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 0-F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 10-1F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 20-2F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 30-3F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 40-4F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 50-5F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 60-6F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 70-7F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 80-8F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 90-9F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$04,$04 ; Levels A0-AF
db $04,$04,$04,$04,$0F,$04,$04,$04,$04,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels B0-BF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels C0-CF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels D0-DF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels E0-EF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels F0-FF
db $0F,$0F,$0F,$0F,$04,$04,$04,$04,$04,$04,$04,$0F,$0F,$0F,$0F,$04 ; Levels 100-10F
db $0F,$04,$0F,$04,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$07 ; Levels 110-11F
db $0F,$0F,$04,$04,$0F,$07,$04,$0F,$0F,$0F,$0F,$0F,$07,$04,$0F,$0F ; Levels 120-12F
db $0F,$0F,$07,$07,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 130-13F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 140-14F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 150-15F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 160-16F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 170-17F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 180-18F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 190-19F
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 1A0-1AF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 1B0-1BF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 1C0-1CF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 1D0-1DF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 1E0-1EF
db $0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ; Levels 1F0-1FF
End:
print bytes