Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BasicUpstart2(start) // <- This creates a basic sys line that can start your program
- //----------------------------------------------------------
- //----------------------------------------------------------
- // Simple IRQ
- //----------------------------------------------------------
- //----------------------------------------------------------
- .var music = LoadSid("Bijelo_dugme.sid") //<- Here we load the sid file
- * = $4000 "Main Program" // <- The name 'Main program' will appear in the memory map when assembling
- start:
- jsr cls // Clear screen
- lda #$0f // use gray color
- jsr $e536 // paint the screen gray
- dex
- stx $d011 // Generate raster line at $40/#64
- jsr scroll_reset
- lda #music.startSong-1 //<- Here we get the startsong and init address from the sid file
- jsr music.init
- // lda #$00 // Tune #0
- // jsr music_init // Initialize music
- sei
- lda #$35 //
- // Processor port. Bits:
- // Bits #0-#2: Configuration for memory areas $A000-$BFFF, $D000-$DFFF and $E000-$FFFF. Values:
- // %x00: RAM visible in all three areas.
- // %x01: RAM visible at $A000-$BFFF and $E000-$FFFF.
- // %x10: RAM visible at $A000-$BFFF; KERNAL ROM visible at $E000-$FFFF.
- // %x11: BASIC ROM visible at $A000-$BFFF; KERNAL ROM visible at $E000-$FFFF.
- // %0xx: Character ROM visible at $D000-$DFFF. (Except for the value %000, see above.)
- // %1xx: I/O area visible at $D000-$DFFF. (Except for the value %100, see above.)
- // Bit #3: Datasette output signal level.
- // Bit #4: Datasette button status; 0 = One or more of PLAY, RECORD, F.FWD or REW pressed; 1 = No button is pressed.
- // Bit #5: Datasette motor control; 0 = On; 1 = Off.
- // Default: $37, %00110111.
- // $01=$37 -> Basic Rom visible A000-C000, IO visible at D000-E000, Kernal Rom Visible at E000-FFFF
- // $01=$36 -> RAM visible A000-C000, IO visible at D000-E000, Kernal Rom Visible at E000-FFFF
- // $01=$35 -> RAM visible A000-C000, IO visible at D000-E000, RAM Visible at E000-FFFF
- // $01=$34 -> RAM visible A000-C000, RAM visible at D000-E000, RAM Visible at E000-FFFF
- // $01=$33 -> RAM visible A000-C000, CHAR ROM at D000-E000, RAM Visible at E000-FFFF
- sta $01 // Set processor bits
- lda #00 // Interrupt at raster line #0
- ldx #<irq // IRQ low byte
- ldy #>irq // IRQ high byte
- jsr irqset // set IRQ registers
- dec $dc0e // Timer A control register
- inc $d01a // Interrupt control register. Bits:
- // Bit #0: 1 = Raster interrupt enabled.
- // Bit #1: 1 = Sprite-background collision interrupt enabled.
- // Bit #2: 1 = Sprite-sprite collision interrupt enabled.
- // Bit #3: 1 = Light pen interrupt enabled.
- ldx #$c1 // $fe47 = nmi handler
- ldy #$fe // $fec1 = rti
- stx $fffa // nmi low byte
- sty $fffb // nmi high byte
- cli
- lda #$ef // space
- w: cmp $dc01 // compare to pressed key
- bne w // loop
- rts
- irq:
- sta ar+1 // save A register
- stx ax+1 // save X register
- sty ay+1 // save Y register
- inc $d019 // acknowledge interrupt
- lda #30
- cmp $d012
- bne *-3
- SetBorderColor(RED)
- jsr scroll
- SetBorderColor(BLUE)
- lda #$1b // screen on, screen hegith 25, vertical raster scroll
- ldx #%00010110 // #$15 = 0001 1011 = screen at $0400
- //ldy #$08 // Multicolor mode on
- ldy $a5 // read $a5 from scroll subroutine
- jsr scs
- lda #51
- cmp $d012
- bne *-3
- SetBorderColor(RED) // <- This is how macros are executed
- jsr music.play
- // jsr music_play
- SetBorderColor(BLACK) // <- There are predefined constants for colors
- SetBorderColor(BLUE)
- ar: lda #$00
- ax: ldx #$00
- ay: ldy #$00
- rti
- /*
- // 1x1 Scroll routine
- //
- // jsr scroll_reset before IRQ to setup parameters
- // byte values $80-86 speeds 1-7
- // $a3/$a4 - SCROLL LO/HI address bytas
- // $a5 - $d016 value
- */
- scroll: lda $a5
- clc
- scroll_speed:
- sbc #$03
- cmp #$c0
- bcs sc6
- adc #$08
- sta $a5
- ldx #$00
- sc1: lda $07c1,x // bottom last line address+1
- sta $07c0,x // bottom last line address
- inx
- cpx #$27
- bne sc1
- ldy #$00
- lda ($a3),y
- bne sc2
- scroll_addr:
- ldx #<scrolltext
- ldy #>scrolltext
- stx $a3
- sty $a4
- rts
- scroll_reset:
- lda #$c8
- sta $a5
- bne scroll_addr
- sc2: cmp scroll_speeds,y
- beq scroll_set_speed
- iny
- cpy #$07
- bne sc2
- sta $07e7
- sc4: inc $a3
- bne sc5
- inc $a4
- sc5: rts
- scroll_set_speed:
- sty scroll_speed+1
- jmp sc4
- sc6: sta $a5
- rts
- scroll_speeds:
- .byte $80,$81,$82,$83,$84,$85,$86
- * = $0900 "Scroll Text"
- scrolltext:
- .byte $80
- .text "this is test speed1 "
- .byte $81
- .text " THIS IS TEST SPEED2 "
- .text "@" // end of scroll
- cls: // Clear screen and initialize everything
- jsr $ff5b // initialise the screen and keyboard
- reset: jsr $fda3 // initialise SID, CIA and IRQ
- jsr $fd15 // restore default I/O vectors
- jsr $e453 // initialise the BASIC vector table
- jmp $e3bf // initialise BASIC RAM locations
- irqset: // Set IRQ registers
- sty $ffff // IRQ high bit : Default $fe48 **IRQ vector
- stx $fffe // IRQ low bit
- sta $d012 // Read: Current raster line (bits #0-#7).
- // Write: Raster line to generate interrupt at (bits #0-#7).
- inc $d019 // Acknowledge raster interrupt
- rts
- irqexit: jsr irqset // Set IRQ registers
- rti
- scs: sta $d011 // Screen control register #1. Bits:
- // Bits #0-#2: Vertical raster scroll.
- // Bit #3: Screen height; 0 = 24 rows; 1 = 25 rows.
- // Bit #4: 0 = Screen off, complete screen is covered by border; 1 = Screen on, normal screen contents are visible.
- // Bit #5: 0 = Text mode; 1 = Bitmap mode.
- // Bit #6: 1 = Extended background mode on.
- // Bit #7: Read: Current raster line (bit #8).
- // Write: Raster line to generate interrupt at (bit #8).
- // Default: $1B, %00011011.
- stx $d018 // Memory setup register. Bits:
- // Bits #1-#3: In text mode, pointer to character memory (bits #11-#13), relative to VIC bank, memory address $DD00. Values:
- // %000, 0: $0000-$07FF, 0-2047.
- // %001, 1: $0800-$0FFF, 2048-4095.
- // %010, 2: $1000-$17FF, 4096-6143.
- // %011, 3: $1800-$1FFF, 6144-8191.
- // %100, 4: $2000-$27FF, 8192-10239.
- // %101, 5: $2800-$2FFF, 10240-12287.
- // %110, 6: $3000-$37FF, 12288-14335.
- // %111, 7: $3800-$3FFF, 14336-16383.
- // Values %010 and %011 in VIC bank #0 and #2 select Character ROM instead.
- // In bitmap mode, pointer to bitmap memory (bit #13), relative to VIC bank, memory address $DD00. Values:
- // %0xx, 0: $0000-$1FFF, 0-8191.
- // %1xx, 4: $2000-$3FFF, 8192-16383.
- // Bits #4-#7: Pointer to screen memory (bits #10-#13), relative to VIC bank, memory address $DD00. Values:
- // %0000, 0: $0000-$03FF, 0-1023.
- // %0001, 1: $0400-$07FF, 1024-2047.
- // %0010, 2: $0800-$0BFF, 2048-3071.
- // %0011, 3: $0C00-$0FFF, 3072-4095.
- // %0100, 4: $1000-$13FF, 4096-5119.
- // %0101, 5: $1400-$17FF, 5120-6143.
- // %0110, 6: $1800-$1BFF, 6144-7167.
- // %0111, 7: $1C00-$1FFF, 7168-8191.
- // %1000, 8: $2000-$23FF, 8192-9215.
- // %1001, 9: $2400-$27FF, 9216-10239.
- // %1010, 10: $2800-$2BFF, 10240-11263.
- // %1011, 11: $2C00-$2FFF, 11264-12287.
- // %1100, 12: $3000-$33FF, 12288-13311.
- // %1101, 13: $3400-$37FF, 13312-14335.
- // %1110, 14: $3800-$3BFF, 14336-15359.
- // %1111, 15: $3C00-$3FFF, 15360-16383.
- sty $d016 // Screen control register #2. Bits:
- // Bits #0-#2: Horizontal raster scroll.
- // Bit #3: Screen width; 0 = 38 columns; 1 = 40 columns.
- // Bit #4: 1 = Multicolor mode on.
- // Default: $C8, %11001000.
- rts
- //----------------------------------------------------------
- // A little macro
- .macro SetBorderColor(color) { // <- This is how macros are defined
- lda #color
- sta $d020
- }
- /*
- //----------------------------------------------------------
- *=$1000 "Music"
- .label music_init =* // <- You can define label with any value (not just at the current pc position as in 'music_init:')
- .label music_play =*+3 // <- and that is useful here
- .import binary "Bijelo_dugme.sid" // <- import is used for importing files (binary, source, c64 or text)
- //----------------------------------------------------------
- */
- //---------------------------------------------------------
- *=music.location "Music"
- .fill music.size, music.getData(i) // <- Here we put the music in memory
- //----------------------------------------------------------
- // Print the music info while assembling
- .print ""
- .print "SID Data"
- .print "--------"
- .print "location=$"+toHexString(music.location)
- .print "init=$"+toHexString(music.init)
- .print "play=$"+toHexString(music.play)
- .print "songs="+music.songs
- .print "startSong="+music.startSong
- .print "size=$"+toHexString(music.size)
- .print "name="+music.name
- .print "author="+music.author
- .print "copyright="+music.copyright
- .print ""
- .print "Additional tech data"
- .print "--------------------"
- .print "header="+music.header
- .print "header version="+music.version
- .print "flags="+toBinaryString(music.flags)
- .print "speed="+toBinaryString(music.speed)
- .print "startpage="+music.startpage
- .print "pagelength="+music.pagelength
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement