;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;HDMA Diagonal Layer 2 Waves ;by KilloZapit, modified by Ice Man ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; lorom ;\ ROM is LoRom header ;| and has a header org $228000 ;/ Address to insert code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;RATS Tag Macro ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; macro RATS_start(id) db "STAR" dw RATS_Endcode-RATS_Startcode dw RATS_Endcode-RATS_Startcode^#$FFFF RATS_Startcode: endmacro macro RATS_end(id) RATS_Endcode: endmacro ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;HDMA Channel Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %RATS_start(0) REP #$20 ;\ Set processor 16 bit LDA #$0F03 ;| $4340 = $210F STA $4340 ;| $4341 = Mode 03 LDA #$9F00 ;| STA $4342 ;| Destination: $7F9F00 LDY #$7F ;| (low and high byte) STY $4344 ;| SEP #$20 ;/ Set processor 8 bit LDA #$10 ;\ Enable HDMA TSB $0D9F ;/ on channel 4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;HDMA Main Code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LDX #$00 ;\ Init of LDY #$00 ;/ X and Y SEP #$20 ;\ Set processor 8 bit LDA $13 ;| Set speed of waves LSR A ;| Adding more LSR A LSR A ;| will make it slower STA $00 ;/ Store in scratch RAM PHB ;\ Push data bank PHK ;| Push program bank PLB ;/ Pull data bank Wave_Loop: LDA #$06 ;\ Set scanline height STA $7F9F00,x ;| for each wave TYA ;| Transfer Y to A ADC $00 ;| Add in scratch RAM AND #$0F ;| and transfer #$0F bytes PHY ;| Push Y TAY ;/ Transfer A to Y LDA.w Wave_Table,y ;\ Load in wave values LSR A ;| half of waves only CLC ;| Clear carry flag ADC $1466 ;| Apply to layer 2 STA $7F9F01,x ;| X position low byte LDA $1467 ;| And add nothing to ADC #$00 ;| layer 2 X position STA $7F9F02,x ;/ high byte LDA.w Wave_Table,y ;\ Load in wave values CLC ;| Clear carry flag ADC $1468 ;| Apply to layer 2 STA $7F9F03,x ;| Y position low byte LDA $1469 ;| And add nothing to ADC #$00 ;| layer 2 Y position STA $7F9F04,x ;/ high byte PLY ;\ Pull Y CPY #$25 ;| Compare with #$25 scanlines BPL End_Wave ;| If bigger, end HDMA INX ;| Increase X INX ;| Increase X INX ;| Increase X INX ;| Increase X INX ;| Increase X INY ;| Increase Y BRA Wave_Loop ;/ Do the loop End_Wave: PLB ;\ Pull data bank LDA #$00 ;| End HMDA by writing STA $7F9F05,x ;| #$00 here RTL ;/ Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Table Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Wave_Table: db $00 db $01 db $02 db $03 db $04 db $05 db $06 db $07 db $07 db $06 db $05 db $04 db $03 db $02 db $01 db $00 %RATS_end(0)