Advertisement
Er0l

Untitled

Feb 27th, 2017
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.99 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.  
  17. jsr scroll_reset
  18.  
  19. lda #music.startSong-1 //<- Here we get the startsong and init address from the sid file
  20. jsr music.init
  21. // lda #$00 // Tune #0
  22. // jsr music_init // Initialize music
  23. sei
  24. lda #$35 //
  25. // Processor port. Bits:
  26. // Bits #0-#2: Configuration for memory areas $A000-$BFFF, $D000-$DFFF and $E000-$FFFF. Values:
  27. // %x00: RAM visible in all three areas.
  28. // %x01: RAM visible at $A000-$BFFF and $E000-$FFFF.
  29. // %x10: RAM visible at $A000-$BFFF; KERNAL ROM visible at $E000-$FFFF.
  30. // %x11: BASIC ROM visible at $A000-$BFFF; KERNAL ROM visible at $E000-$FFFF.
  31. // %0xx: Character ROM visible at $D000-$DFFF. (Except for the value %000, see above.)
  32. // %1xx: I/O area visible at $D000-$DFFF. (Except for the value %100, see above.)
  33. // Bit #3: Datasette output signal level.
  34. // Bit #4: Datasette button status; 0 = One or more of PLAY, RECORD, F.FWD or REW pressed; 1 = No button is pressed.
  35. // Bit #5: Datasette motor control; 0 = On; 1 = Off.
  36. // Default: $37, %00110111.
  37. // $01=$37 -> Basic Rom visible A000-C000, IO visible at D000-E000, Kernal Rom Visible at E000-FFFF
  38. // $01=$36 -> RAM visible A000-C000, IO visible at D000-E000, Kernal Rom Visible at E000-FFFF
  39. // $01=$35 -> RAM visible A000-C000, IO visible at D000-E000, RAM Visible at E000-FFFF
  40. // $01=$34 -> RAM visible A000-C000, RAM visible at D000-E000, RAM Visible at E000-FFFF
  41. // $01=$33 -> RAM visible A000-C000, CHAR ROM at D000-E000, RAM Visible at E000-FFFF
  42.  
  43.  
  44. sta $01 // Set processor bits
  45. lda #00 // Interrupt at raster line #0
  46. ldx #<irq // IRQ low byte
  47. ldy #>irq // IRQ high byte
  48. jsr irqset // set IRQ registers
  49. dec $dc0e // Timer A control register
  50. inc $d01a // Interrupt control register. Bits:
  51. // Bit #0: 1 = Raster interrupt enabled.
  52. // Bit #1: 1 = Sprite-background collision interrupt enabled.
  53. // Bit #2: 1 = Sprite-sprite collision interrupt enabled.
  54. // Bit #3: 1 = Light pen interrupt enabled.
  55. ldx #$c1 // $fe47 = nmi handler
  56. ldy #$fe // $fec1 = rti
  57. stx $fffa // nmi low byte
  58. sty $fffb // nmi high byte
  59. cli
  60. lda #$ef // space
  61. w: cmp $dc01 // compare to pressed key
  62. bne w // loop
  63. rts
  64.  
  65.  
  66. irq:
  67. sta ar+1 // save A register
  68. stx ax+1 // save X register
  69. sty ay+1 // save Y register
  70.  
  71. inc $d019 // acknowledge interrupt
  72.  
  73. lda #30
  74. cmp $d012
  75. bne *-3
  76.  
  77. SetBorderColor(RED)
  78. jsr scroll
  79. SetBorderColor(BLUE)
  80.  
  81. lda #$1b // screen on, screen hegith 25, vertical raster scroll
  82. ldx #%00010110 // #$15 = 0001 1011 = screen at $0400
  83. //ldy #$08 // Multicolor mode on
  84. ldy $a5 // read $a5 from scroll subroutine
  85. jsr scs
  86.  
  87. lda #51
  88. cmp $d012
  89. bne *-3
  90. SetBorderColor(RED) // <- This is how macros are executed
  91. jsr music.play
  92. // jsr music_play
  93. SetBorderColor(BLACK) // <- There are predefined constants for colors
  94.  
  95.  
  96. SetBorderColor(BLUE)
  97.  
  98.  
  99.  
  100. ar: lda #$00
  101. ax: ldx #$00
  102. ay: ldy #$00
  103. rti
  104.  
  105. /*
  106. // 1x1 Scroll routine
  107. //
  108. // jsr scroll_reset before IRQ to setup parameters
  109. // byte values $80-86 speeds 1-7
  110. // $a3/$a4 - SCROLL LO/HI address bytas
  111. // $a5 - $d016 value
  112. */
  113. scroll: lda $a5
  114. clc
  115. scroll_speed:
  116. sbc #$03
  117. cmp #$c0
  118. bcs sc6
  119. adc #$08
  120. sta $a5
  121. ldx #$00
  122. sc1: lda $07c1,x // bottom last line address+1
  123. sta $07c0,x // bottom last line address
  124. inx
  125. cpx #$27
  126. bne sc1
  127. ldy #$00
  128. lda ($a3),y
  129. bne sc2
  130. scroll_addr:
  131. ldx #<scrolltext
  132. ldy #>scrolltext
  133. stx $a3
  134. sty $a4
  135. rts
  136. scroll_reset:
  137. lda #$c8
  138. sta $a5
  139. bne scroll_addr
  140. sc2: cmp scroll_speeds,y
  141. beq scroll_set_speed
  142. iny
  143. cpy #$07
  144. bne sc2
  145. sta $07e7
  146. sc4: inc $a3
  147. bne sc5
  148. inc $a4
  149. sc5: rts
  150. scroll_set_speed:
  151. sty scroll_speed+1
  152. jmp sc4
  153. sc6: sta $a5
  154. rts
  155. scroll_speeds:
  156. .byte $80,$81,$82,$83,$84,$85,$86
  157.  
  158. * = $0900 "Scroll Text"
  159. scrolltext:
  160. .byte $80
  161. .text "this is test speed1 "
  162. .byte $81
  163. .text " THIS IS TEST SPEED2 "
  164. .text "@" // end of scroll
  165.  
  166.  
  167. cls: // Clear screen and initialize everything
  168. jsr $ff5b // initialise the screen and keyboard
  169. reset: jsr $fda3 // initialise SID, CIA and IRQ
  170. jsr $fd15 // restore default I/O vectors
  171. jsr $e453 // initialise the BASIC vector table
  172. jmp $e3bf // initialise BASIC RAM locations
  173.  
  174. irqset: // Set IRQ registers
  175. sty $ffff // IRQ high bit : Default $fe48 **IRQ vector
  176. stx $fffe // IRQ low bit
  177. sta $d012 // Read: Current raster line (bits #0-#7).
  178. // Write: Raster line to generate interrupt at (bits #0-#7).
  179. inc $d019 // Acknowledge raster interrupt
  180. rts
  181. irqexit: jsr irqset // Set IRQ registers
  182. rti
  183. scs: sta $d011 // Screen control register #1. Bits:
  184. // Bits #0-#2: Vertical raster scroll.
  185. // Bit #3: Screen height; 0 = 24 rows; 1 = 25 rows.
  186. // Bit #4: 0 = Screen off, complete screen is covered by border; 1 = Screen on, normal screen contents are visible.
  187. // Bit #5: 0 = Text mode; 1 = Bitmap mode.
  188. // Bit #6: 1 = Extended background mode on.
  189. // Bit #7: Read: Current raster line (bit #8).
  190. // Write: Raster line to generate interrupt at (bit #8).
  191. // Default: $1B, %00011011.
  192. stx $d018 // Memory setup register. Bits:
  193. // Bits #1-#3: In text mode, pointer to character memory (bits #11-#13), relative to VIC bank, memory address $DD00. Values:
  194. // %000, 0: $0000-$07FF, 0-2047.
  195. // %001, 1: $0800-$0FFF, 2048-4095.
  196. // %010, 2: $1000-$17FF, 4096-6143.
  197. // %011, 3: $1800-$1FFF, 6144-8191.
  198. // %100, 4: $2000-$27FF, 8192-10239.
  199. // %101, 5: $2800-$2FFF, 10240-12287.
  200. // %110, 6: $3000-$37FF, 12288-14335.
  201. // %111, 7: $3800-$3FFF, 14336-16383.
  202. // Values %010 and %011 in VIC bank #0 and #2 select Character ROM instead.
  203. // In bitmap mode, pointer to bitmap memory (bit #13), relative to VIC bank, memory address $DD00. Values:
  204. // %0xx, 0: $0000-$1FFF, 0-8191.
  205. // %1xx, 4: $2000-$3FFF, 8192-16383.
  206. // Bits #4-#7: Pointer to screen memory (bits #10-#13), relative to VIC bank, memory address $DD00. Values:
  207. // %0000, 0: $0000-$03FF, 0-1023.
  208. // %0001, 1: $0400-$07FF, 1024-2047.
  209. // %0010, 2: $0800-$0BFF, 2048-3071.
  210. // %0011, 3: $0C00-$0FFF, 3072-4095.
  211. // %0100, 4: $1000-$13FF, 4096-5119.
  212. // %0101, 5: $1400-$17FF, 5120-6143.
  213. // %0110, 6: $1800-$1BFF, 6144-7167.
  214. // %0111, 7: $1C00-$1FFF, 7168-8191.
  215. // %1000, 8: $2000-$23FF, 8192-9215.
  216. // %1001, 9: $2400-$27FF, 9216-10239.
  217. // %1010, 10: $2800-$2BFF, 10240-11263.
  218. // %1011, 11: $2C00-$2FFF, 11264-12287.
  219. // %1100, 12: $3000-$33FF, 12288-13311.
  220. // %1101, 13: $3400-$37FF, 13312-14335.
  221. // %1110, 14: $3800-$3BFF, 14336-15359.
  222. // %1111, 15: $3C00-$3FFF, 15360-16383.
  223. sty $d016 // Screen control register #2. Bits:
  224. // Bits #0-#2: Horizontal raster scroll.
  225. // Bit #3: Screen width; 0 = 38 columns; 1 = 40 columns.
  226. // Bit #4: 1 = Multicolor mode on.
  227. // Default: $C8, %11001000.
  228. rts
  229. //----------------------------------------------------------
  230. // A little macro
  231. .macro SetBorderColor(color) { // <- This is how macros are defined
  232. lda #color
  233. sta $d020
  234. }
  235. /*
  236. //----------------------------------------------------------
  237. *=$1000 "Music"
  238. .label music_init =* // <- You can define label with any value (not just at the current pc position as in 'music_init:')
  239. .label music_play =*+3 // <- and that is useful here
  240. .import binary "Bijelo_dugme.sid" // <- import is used for importing files (binary, source, c64 or text)
  241.  
  242. //----------------------------------------------------------
  243. */
  244. //---------------------------------------------------------
  245. *=music.location "Music"
  246. .fill music.size, music.getData(i) // <- Here we put the music in memory
  247.  
  248. //----------------------------------------------------------
  249. // Print the music info while assembling
  250. .print ""
  251. .print "SID Data"
  252. .print "--------"
  253. .print "location=$"+toHexString(music.location)
  254. .print "init=$"+toHexString(music.init)
  255. .print "play=$"+toHexString(music.play)
  256. .print "songs="+music.songs
  257. .print "startSong="+music.startSong
  258. .print "size=$"+toHexString(music.size)
  259. .print "name="+music.name
  260. .print "author="+music.author
  261. .print "copyright="+music.copyright
  262.  
  263. .print ""
  264. .print "Additional tech data"
  265. .print "--------------------"
  266. .print "header="+music.header
  267. .print "header version="+music.version
  268. .print "flags="+toBinaryString(music.flags)
  269. .print "speed="+toBinaryString(music.speed)
  270. .print "startpage="+music.startpage
  271. .print "pagelength="+music.pagelength
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement