;Assemble It - Tutorial ;---------------------- ;Producing a demo which uses a 1x2 ;scrolltext using sources like a ;split up bitmap picture, colour ;rolling and also play music message = $5000 soft = $05 fishpos = $0370 ;NOTE before you use the .binary command for your assembler, ;make sure you have extracted the data prg files from a .D64 ;into the same folder where this code is stored. Be sure to ;rename those .PRG files. ;Insert music data file. *=$1000-2 ;DASM users, use PROCESSOR 6502 (once) and then ORG $1000, KICKASS use .PC $1000-2 .binary "music.prg" ;DASM, use INCBIN, ACME use !BIN or !BINARY. ;Insert 1x2 charset *=$2000-2 ; .binary "1x2charset.prg" ;Insert sprites *= $4000 .binary "sprites.prg" *= $4800 sei lda #$00 sta $d020 lda #$07 sta $d021 ;Prepare sprites lda #$ff ;turn 'em on sta $d015 ;no. of sprites = 8 sta $d01c ;multicolour lda #$00 ;disable expanded sta $d017 ;sprites sta $d01d ; lda #$fe ; sta $07f8 ; sta $07fa ; sta $07fc ; sta $07fe ; lda #$ff ; sta $07f9 ; sta $07fb ; sta $07fd ; sta $07ff ; lda #$0d sta $d025 ;multicolour mode1 lda #$0b sta $d026 ;multicolour mode2 lda #$05 sta $d027 ;the main colour for sta $d028 ;the sprites. sta $d029 ; sta $d02a ; sta $d02b ; sta $d02c ; sta $d02d ; sta $d02e ; ;Call a loop to set start position for ;all fish accordingly to the table ldx #$00 posloop lda pos+$00,x sta fishpos+$00,x inx cpx #$10 bne posloop ;The first thing which we are going ;to do is fill the screen with the ;data for the video RAM and the ;colour RAM of the bitmap picture ldx #$00 copydat lda $4000,x ;This part here sta $0400,x ;reads all data lda $4100,x ;from $4000 and sta $0500,x ;pastes all the lda $4200,x ;data to the sta $0600,x ;SCREEN in bank lda $42e8,x ;3 sta $06e8,x lda $4400,x ;This part reads sta $d800,x ;all the data lda $4500,x ;from $4400 and sta $d900,x ;then pastes all lda $4600,x ;data into the sta $da00,x ;COLOUR RAM lda $46e8,x sta $dae8,x inx ;Count 256 times bne copydat ;else loop ;Clear bottom bit so you get no mess ;when you start a scrolltext ldx #$00 blank lda #$20 sta $0798,x inx cpx #$50 bne blank ;Initialise the scrolltext lda #message sta read+2 ;Prepare and initialise the IRQ raster ;interrupt lda #int sta $0315 lda #$00 sta $d012 ;init rasterline lda #$7f sta $dc0d lda #$01 sta $d019 sta $d01a ;Initialise the music at $1000 lda #$00 tax tay jsr $1000 cli ;clear irq flag hold jmp hold ;Now play and run the IRQ raster ;interrupt to get some effects. int lda $d019 and #$01 sta $d019 bne irq jmp $ea81 ;The main IRQ loops to call our ;routines to slide the scroll, display ;the bitmap, move sprites and also ;properly play the music. irq lda #$00 sta $d012 jsr movefish jsr scrolltext jsr splits jsr $1003 jmp $ea81 ;The usual routine for calling a ;scrolltext. ;You should already know this bit from ;the intro coding chapter scrolltext lda soft sec sbc #$02 ;Scroll speed and #$07 sta soft bcs endscr ldx #$00 wrap lda $0799,x sta $0798,x lda $07c1,x sta $07c0,x inx cpx #$28 bne wrap read lda $07bf cmp #$00 bne setpt lda #message sta read+2 jmp read setpt sta $07bf clc adc #$80 sta $07e7 inc read+1 lda read+1 cmp #$00 bne endscr inc read+2 endscr rts ;Now we do the raster splits for the ;demo. splits lda #$e6 ;bottom of screen cmp $d012 ;raster split for bne *-5 ;the colour rolling ldy #$0c ;scrolltext. dey bne *-4 lda #$1b ;char mode sta $d011 ; lda #$12 ; sta $d018 ;char at $0800-$1000 lda soft ;smooth scroll sta $d016 ;is set ldx #$00 loop1 ldy timing,x ;a special loop2 dey ;routine that bne loop2 ;makes those nice lda colours,x ;multicolour bars sta $d021 inx cpx #$10 bne loop1 lda #$fd ;our second split cmp $d012 ; bne *-5 lda #$3b ;bitmap mode sta $d011 lda #$18 ;charset for the sta $d018 ;bitmap and turn sta $d016 ;on screen multic lda #$07 ;yellow bckground sta $d021 ;(fish pic's eye) ;roll those colourdatas so we can have a ;cool colour scroll. colroll lda colours+$00 ;you should sta colours+$0f ;already know ldx #$00 ;this section. rolloop lda colours+$01,x;its a loop sta colours+$00,x;that will inx ;scroll data cpx #$0f ;tables. bne rolloop ; rts ; ;move those sprites and expand the ;sprite position movefish lda fishpos+$00 ;you should be clc ;familiar with adc #$01 ;this thing sta fishpos+$00 ;hopefully lda fishpos+$02 ; sec ;subtract 1 sbc #$01 ;to speed sta fishpos+$02 lda fishpos+$04 clc ;add 2 adc #$02 ;to speed sta fishpos+$04 lda fishpos+$06 sec sbc #$02 ;subtract 2 sta fishpos+$06 ;to speed lda fishpos+$08 clc adc #$03 ;add 3 to speed sta fishpos+$08 lda fishpos+$0a sec ;subtract 3 to sbc #$03 ;speed sta fishpos+$0a lda fishpos+$0c clc adc #$02 sta fishpos+$0c lda fishpos+$0e sec sbc #$02 sta fishpos+$0e ;expand the positioning of the sprites ;so that they can move more than 256 ;pixels. ldx #$00 ; take a look exppos lda fishpos+$01,x ; at the sta $d001,x ; missile lda fishpos+$00,x ; blasta code asl a ; to really ror $d010 ; understand sta $d000,x ; what this inx ; routine inx ; does cpx #$10 ; bne exppos ; rts ; ;data tables for the colour scroll and ;timing of the colourscroll ;DASM users, use dc.b, ACME use !BYTE colours .byte $06,$0e,$03,$01 .byte $03,$0e,$06,$00 .byte $02,$0a,$07,$01 .byte $07,$0a,$02,$00 timing .byte $0c,$0c,$0c,$0c .byte $0c,$0c,$0c,$0c .byte $0c,$0c,$0c,$0c .byte $0c,$0c,$0c,$0c fishpd .byte $01,$02,$03,$02 .byte $ff,$fe,$ff,$fd pos .byte $00,$40,$00,$50 .byte $00,$60,$00,$70 .byte $00,$80,$00,$90 .byte $00,$a0,$00,$b0 ;Now insert the scroll text *=$5000-2 .binary "scrolltext.prg" ;Insert the vidcom painter picture *=$5800-2 .binary "b.picture.prg" ;END!