REP #$20 ;\ Set processor 16 bit LDA #$0F02 ;| $4340 = $210F STA $4340 ;| $4341 = Mode 02 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 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 INY ;| Increase Y BRA Wave_Loop ;/ Do the loop End_Wave: PLB ;\ Pull data bank LDA #$00 ;| End HMDA by writing STA $7F9F03,x ;| #$00 here RTS ;/ 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