home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / cncd_editor.zip / example1.asm < prev    next >
Assembly Source File  |  2001-01-09  |  2KB  |  77 lines

  1. Player_Initialize       equ     $4000
  2. Player_MusicStart       equ     $4003
  3. Player_MusicStop        equ     $4006
  4. Player_SongSelect       equ     $400c
  5. Player_MusicUpdate      equ     $4100
  6.  
  7. MusicBank               equ     1
  8.  
  9. SongNumber              equ     0       ; 0 - 7
  10.  
  11.  
  12.  
  13.         SECTION "Example",HOME[$150]
  14.  
  15. FirstTime:
  16.         ld      a,MusicBank             ; Switch to MusicBank
  17.         ld      [rROMB0],a
  18.  
  19.         call    Player_Initialize       ; Initialize sound registers and
  20.                                         ; player variables on startup
  21.  
  22. NewSong:
  23.         ld      a,MusicBank             ; Switch to MusicBank
  24.         ld      [rROMB0],a
  25.  
  26.         call    Player_MusicStart       ; Start music playing
  27.  
  28.         ld      a,SongNumber            ; Call SongSelect AFTER MusicStart!
  29.         call    Player_SongSelect       ; (Not needed if SongNumber = 0)
  30.  
  31.  
  32. FrameLoop:
  33.         ld      c,$10                   ; Waiting
  34.         call    WaitLCDLine
  35.  
  36.         ld      a,MusicBank             ; Switch to MusicBank
  37.         ld      [rROMB0],a
  38.         call    Player_MusicUpdate      ; Call this once a frame
  39.  
  40.         ;call   YourProgram
  41.  
  42.         ld      c,$90                   ; Wait for VBlank
  43.         call    WaitLCDLine
  44.  
  45.         ; VBlank routines here
  46.  
  47.         jr      FrameLoop
  48.  
  49.  
  50.  
  51. StopExample:
  52.         ld      a,MusicBank             ; Switch to MusicBank
  53.         ld      [rROMB0],a
  54.         call    Player_MusicStop        ; Stops reading note data and cuts
  55.                                         ; all music notes currently playing
  56.         ret
  57.  
  58.  
  59.  
  60. WaitLCDLine:
  61.         ld      a,[rLY]
  62.         cp      c
  63.         jr      nz,WaitLCDLine
  64.         ret
  65.  
  66.  
  67.  
  68.         SECTION "Music",DATA[$4000],BANK[MusicBank]
  69.  
  70.         INCBIN "music.bin"              ; player code and music data
  71.  
  72.  
  73.  
  74.         SECTION "Reserved",BSS[$c7c0]
  75.  
  76.         ds      $30                     ; $c7c0 - $c7ef for player variables
  77.