Advertisement
Er0l

Untitled

Feb 27th, 2017
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.05 KB | None | 0 0
  1. BasicUpstart2(start) // <- This creates a basic sys line that can start your program
  2.  
  3. //----------------------------------------------------------
  4. //----------------------------------------------------------
  5. // Simple IRQ
  6. //----------------------------------------------------------
  7. //----------------------------------------------------------
  8. .var music = LoadSid("Bijelo_dugme.sid") //<- Here we load the sid file
  9. * = $4000 "Main Program" // <- The name 'Main program' will appear in the memory map when assembling
  10. start:
  11. jsr cls // Clear screen
  12. lda #$0f // use gray color
  13. jsr $e536 // paint the screen gray
  14. dex
  15. stx $d011 // Generate raster line at $40/#64
  16. ldx #0
  17. lda #65
  18. fill: sta $0400,x
  19. inx
  20. bne fill
  21. lda #music.startSong-1 //<- Here we get the startsong and init address from the sid file
  22. jsr music.init
  23. // lda #$00 // Tune #0
  24. // jsr music_init // Initialize music
  25. sei
  26. lda #$35 //
  27. // Processor port. Bits:
  28. // Bits #0-#2: Configuration for memory areas $A000-$BFFF, $D000-$DFFF and $E000-$FFFF. Values:
  29. // %x00: RAM visible in all three areas.
  30. // %x01: RAM visible at $A000-$BFFF and $E000-$FFFF.
  31. // %x10: RAM visible at $A000-$BFFF; KERNAL ROM visible at $E000-$FFFF.
  32. // %x11: BASIC ROM visible at $A000-$BFFF; KERNAL ROM visible at $E000-$FFFF.
  33. // %0xx: Character ROM visible at $D000-$DFFF. (Except for the value %000, see above.)
  34. // %1xx: I/O area visible at $D000-$DFFF. (Except for the value %100, see above.)
  35. // Bit #3: Datasette output signal level.
  36. // Bit #4: Datasette button status; 0 = One or more of PLAY, RECORD, F.FWD or REW pressed; 1 = No button is pressed.
  37. // Bit #5: Datasette motor control; 0 = On; 1 = Off.
  38. // Default: $37, %00110111.
  39. sta $01 // Set processor bits
  40. lda #00 // Interrupt at raster line #0
  41. ldx #<irq // IRQ low byte
  42. ldy #>irq // IRQ high byte
  43. jsr irqset // set IRQ registers
  44. dec $dc0e // Timer A control register
  45. inc $d01a // Interrupt control register. Bits:
  46. // Bit #0: 1 = Raster interrupt enabled.
  47. // Bit #1: 1 = Sprite-background collision interrupt enabled.
  48. // Bit #2: 1 = Sprite-sprite collision interrupt enabled.
  49. // Bit #3: 1 = Light pen interrupt enabled.
  50. ldx #$c1 // $fe47 = nmi handler
  51. ldy #$fe // $fec1 = rti
  52. stx $fffa // nmi low byte
  53. sty $fffb // nmi high byte
  54. cli
  55. lda #$ef // space
  56. w: cmp $dc01 // compare to pressed key
  57. bne w // loop
  58. rts
  59.  
  60.  
  61. irq:
  62. sta ar+1 // save A register
  63. stx ax+1 // save X register
  64. sty ay+1 // save Y register
  65.  
  66. inc $d019 // acknowledge interrupt
  67. lda #$1b // screen on, screen hegith 25, vertical raster scroll
  68. ldx #$15 // #$15 = 0001 1011 = screen at $0400
  69. ldy #$08 // Multicolor mode on
  70. jsr scs
  71.  
  72. lda #51
  73. cmp $d012
  74. bne *-3
  75. SetBorderColor(RED) // <- This is how macros are executed
  76. jsr music.play
  77. // jsr music_play
  78. SetBorderColor(BLACK) // <- There are predefined constants for colors
  79.  
  80.  
  81. SetBorderColor(BLUE)
  82.  
  83.  
  84. ar: lda #$00
  85. ax: ldx #$00
  86. ay: ldy #$00
  87. rti
  88.  
  89. cls: // Clear screen and initialize everything
  90. jsr $ff5b // initialise the screen and keyboard
  91. reset: jsr $fda3 // initialise SID, CIA and IRQ
  92. jsr $fd15 // restore default I/O vectors
  93. jsr $e453 // initialise the BASIC vector table
  94. jmp $e3bf // initialise BASIC RAM locations
  95.  
  96. irqset: // Set IRQ registers
  97. sty $ffff // IRQ high bit : Default $fe48 **IRQ vector
  98. stx $fffe // IRQ low bit
  99. sta $d012 // Read: Current raster line (bits #0-#7).
  100. // Write: Raster line to generate interrupt at (bits #0-#7).
  101. inc $d019 // Acknowledge raster interrupt
  102. rts
  103. irqexit: jsr irqset // Set IRQ registers
  104. rti
  105. scs: sta $d011 // Screen control register #1. Bits:
  106. // Bits #0-#2: Vertical raster scroll.
  107. // Bit #3: Screen height; 0 = 24 rows; 1 = 25 rows.
  108. // Bit #4: 0 = Screen off, complete screen is covered by border; 1 = Screen on, normal screen contents are visible.
  109. // Bit #5: 0 = Text mode; 1 = Bitmap mode.
  110. // Bit #6: 1 = Extended background mode on.
  111. // Bit #7: Read: Current raster line (bit #8).
  112. // Write: Raster line to generate interrupt at (bit #8).
  113. // Default: $1B, %00011011.
  114. stx $d018 // Memory setup register. Bits:
  115. // Bits #1-#3: In text mode, pointer to character memory (bits #11-#13), relative to VIC bank, memory address $DD00. Values:
  116. // %000, 0: $0000-$07FF, 0-2047.
  117. // %001, 1: $0800-$0FFF, 2048-4095.
  118. // %010, 2: $1000-$17FF, 4096-6143.
  119. // %011, 3: $1800-$1FFF, 6144-8191.
  120. // %100, 4: $2000-$27FF, 8192-10239.
  121. // %101, 5: $2800-$2FFF, 10240-12287.
  122. // %110, 6: $3000-$37FF, 12288-14335.
  123. // %111, 7: $3800-$3FFF, 14336-16383.
  124. // Values %010 and %011 in VIC bank #0 and #2 select Character ROM instead.
  125. // In bitmap mode, pointer to bitmap memory (bit #13), relative to VIC bank, memory address $DD00. Values:
  126. // %0xx, 0: $0000-$1FFF, 0-8191.
  127. // %1xx, 4: $2000-$3FFF, 8192-16383.
  128. // Bits #4-#7: Pointer to screen memory (bits #10-#13), relative to VIC bank, memory address $DD00. Values:
  129. // %0000, 0: $0000-$03FF, 0-1023.
  130. // %0001, 1: $0400-$07FF, 1024-2047.
  131. // %0010, 2: $0800-$0BFF, 2048-3071.
  132. // %0011, 3: $0C00-$0FFF, 3072-4095.
  133. // %0100, 4: $1000-$13FF, 4096-5119.
  134. // %0101, 5: $1400-$17FF, 5120-6143.
  135. // %0110, 6: $1800-$1BFF, 6144-7167.
  136. // %0111, 7: $1C00-$1FFF, 7168-8191.
  137. // %1000, 8: $2000-$23FF, 8192-9215.
  138. // %1001, 9: $2400-$27FF, 9216-10239.
  139. // %1010, 10: $2800-$2BFF, 10240-11263.
  140. // %1011, 11: $2C00-$2FFF, 11264-12287.
  141. // %1100, 12: $3000-$33FF, 12288-13311.
  142. // %1101, 13: $3400-$37FF, 13312-14335.
  143. // %1110, 14: $3800-$3BFF, 14336-15359.
  144. // %1111, 15: $3C00-$3FFF, 15360-16383.
  145. sty $d016 // Screen control register #2. Bits:
  146. // Bits #0-#2: Horizontal raster scroll.
  147. // Bit #3: Screen width; 0 = 38 columns; 1 = 40 columns.
  148. // Bit #4: 1 = Multicolor mode on.
  149. // Default: $C8, %11001000.
  150. rts
  151. //----------------------------------------------------------
  152. // A little macro
  153. .macro SetBorderColor(color) { // <- This is how macros are defined
  154. lda #color
  155. sta $d020
  156. }
  157. /*
  158. //----------------------------------------------------------
  159. *=$1000 "Music"
  160. .label music_init =* // <- You can define label with any value (not just at the current pc position as in 'music_init:')
  161. .label music_play =*+3 // <- and that is useful here
  162. .import binary "Bijelo_dugme.sid" // <- import is used for importing files (binary, source, c64 or text)
  163.  
  164. //----------------------------------------------------------
  165. */
  166. //---------------------------------------------------------
  167. *=music.location "Music"
  168. .fill music.size, music.getData(i) // <- Here we put the music in memory
  169.  
  170. //----------------------------------------------------------
  171. // Print the music info while assembling
  172. .print ""
  173. .print "SID Data"
  174. .print "--------"
  175. .print "location=$"+toHexString(music.location)
  176. .print "init=$"+toHexString(music.init)
  177. .print "play=$"+toHexString(music.play)
  178. .print "songs="+music.songs
  179. .print "startSong="+music.startSong
  180. .print "size=$"+toHexString(music.size)
  181. .print "name="+music.name
  182. .print "author="+music.author
  183. .print "copyright="+music.copyright
  184.  
  185. .print ""
  186. .print "Additional tech data"
  187. .print "--------------------"
  188. .print "header="+music.header
  189. .print "header version="+music.version
  190. .print "flags="+toBinaryString(music.flags)
  191. .print "speed="+toBinaryString(music.speed)
  192. .print "startpage="+music.startpage
  193. .print "pagelength="+music.pagelength
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement