SHARE
TWEET

MY FIRST EVER GBS FILE

HertzDevil Jan 30th, 2016 (edited) 147 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .ROMBANKMAP
  2. BANKSTOTAL 4
  3. BANKSIZE $70
  4. BANKS 1
  5. BANKSIZE $4000
  6. BANKS 3
  7. .ENDRO
  8.  
  9. .MEMORYMAP
  10. SLOTSIZE $4000
  11. DEFAULTSLOT 0
  12. SLOT 0 $0000
  13. SLOT 1 $4000
  14. .ENDME
  15.  
  16. ; gbs_wrap.s
  17. .DB "GBS"           ; ident
  18. .DB 1               ; version
  19. .DB 1               ; track count
  20. .DB 1               ; first track
  21. .DW $0000           ; load address
  22. .DW INIT            ; init address
  23. .DW PLAY            ; play address
  24. .DW $FEFF           ; stack pointer
  25. .DB 0               ; timer modulo
  26. .DB 0               ; timer control
  27. .ORG $10            ; title
  28. .DB "TITLE", 0
  29. .ORG $30            ; author
  30. .DB "AUTHOR", 0
  31. .ORG $50            ; copyright
  32. .DB "COPYRIGHT", 0
  33.  
  34. .EMPTYFILL $c9                  ; ret.
  35.  
  36. .DEFINE Clock $C000
  37.  
  38. .BANK 1 SLOT 0
  39. .ORG $0
  40. .SECTION "Main" FORCE
  41. LOAD:
  42. INIT:
  43.     ld  HL, $FF26
  44.     ld  A, $80                  ; sound enable
  45.     ldd (HL), A
  46.     ld  A, %11111111            ; pan
  47.     ldd (HL), A
  48.     ld  A, %01110111            ; master volume
  49.     ldd (HL), A
  50.  
  51.     ld  A, $40
  52.     ldh ($11), A                ; pulse duty / length
  53.     ldh ($16), A
  54.     ld  A, $C4
  55.     ldh ($12), A                ; volume
  56.     ld  A, $95
  57.     ldh ($17), A
  58.    
  59.     ld  HL, Clock
  60.     ld  (HL), 1
  61.     inc HL
  62.     ld  (HL), $3F
  63.     ret
  64.  
  65. PLAY:
  66.     ld  HL, Clock
  67.     ld  A, (HL)
  68.     dec A
  69.     jr  z, +
  70.     ld  (HL), A
  71.     ret
  72. +   ld  A, 6
  73.     ldi (HL), A
  74.     ld  A, (HL)
  75.     inc A
  76.     and $3F
  77.     ld  (HL), A
  78.  
  79.     ld  B, 0
  80.     ld  C, A
  81.  
  82.     ld  HL, cir_pu1
  83.     add HL, BC
  84.     ld  A, (HL)
  85.     cp  $FF
  86.     jr  z, +
  87.     rlca
  88.     ld  D, 0
  89.     ld  E, A
  90.     ld  HL, gb_periods
  91.     add HL, DE
  92.     ldi A, (HL)
  93.     ldh ($13), A
  94.     ldi A, (HL)
  95.     ld  E, $80
  96.     or  E
  97.     ldh ($14), A
  98. +
  99.     ld  HL, cir_pu2
  100.     add HL, BC
  101.     ld  A, (HL)
  102.     cp  $FF
  103.     jr  z, +
  104.     rlca
  105.     ld  D, 0
  106.     ld  E, A
  107.     ld  HL, gb_periods
  108.     add HL, DE
  109.     ldi A, (HL)
  110.     ldh ($18), A
  111.     ldi A, (HL)
  112.     ld  E, $80
  113.     or  E
  114.     ldh ($19), A
  115. +
  116.     ret
  117. .ENDS
  118.  
  119. cir_pu1:
  120. .DB $30,  -1,  -1, $2E,  -1,  -1, $30,  -1
  121. .DB $33,  -1,  -1,  -1,  -1,  -1,  -1,  -1
  122. .DB $30,  -1, $2E,  -1, $30,  -1, $33,  -1
  123. .DB  -1,  -1, $35,  -1, $30,  -1, $2E,  -1
  124. .DB $30,  -1, $2E,  -1, $30,  -1, $33,  -1
  125. .DB  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1
  126. .DB $30,  -1, $2E,  -1, $30,  -1, $37,  -1
  127. .DB  -1,  -1, $37,  -1, $35,  -1,  -1,  -1
  128.  
  129. cir_pu2:
  130. .DB $27,  -1,  -1, $27,  -1,  -1, $27,  -1
  131. .DB $30,  -1,  -1,  -1,  -1,  -1,  -1,  -1
  132. .DB $27,  -1, $27,  -1, $27,  -1, $30,  -1
  133. .DB  -1,  -1, $30,  -1, $2b,  -1, $2B,  -1
  134. .DB $27,  -1, $27,  -1, $27,  -1, $30,  -1
  135. .DB  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1
  136. .DB $27,  -1, $27,  -1, $27,  -1, $33,  -1
  137. .DB  -1,  -1, $33,  -1, $32,  -1,  -1,  -1
  138.  
  139. gb_periods:
  140. .DW $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000
  141. .DW $002C, $009D, $0107, $016B, $01C9, $0223, $0277, $02C7, $0312, $0358, $039B, $03DA
  142. .DW $0416, $044E, $0483, $04B5, $04E5, $0511, $053B, $0563, $0589, $05AC, $05CE, $05ED
  143. .DW $060B, $0627, $0642, $065B, $0672, $0689, $069E, $06B2, $06C4, $06D6, $06E7, $06F7
  144. .DW $0706, $0714, $0721, $072D, $0739, $0744, $074F, $0759, $0762, $076B, $0773, $077B
  145. .DW $0783, $078A, $0790, $0797, $079D, $07A2, $07A7, $07AC, $07B1, $07B6, $07BA, $07BE
  146. .DW $07C1, $07C5, $07C8, $07CB, $07CE, $07D1, $07D4, $07D6, $07D9, $07DB, $07DD, $07DF
  147. .DW $07E1, $07E2, $07E4, $07E6, $07E7, $07E9, $07EA, $07EB, $07EC, $07ED, $07EE, $07EF
  148.  
  149. ; WLA DX is not actually designed with producing non-ROM files in mind
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top