;Assemble IT ;Coding an Old School Demo ;Our global variables for routines message1 = $4000 ;Where scrolltext lies message2 = $4800 ;Where scrolltext lies stillmess = $4d00 ;Area for still message smooth1 = $02 ;$D016 control scroll1 smooth2 = $03 ;$D016 control scroll2 sync = $04 ;Synchronise timer/delay with raster IRQ anim = $05 ;Animation pointer objpos = $0800 ;Sprite object virtual x/y position !to "assembleitdemo2.prg",cbm *=$0801 !basic $0900 *= $0900 ;KickAssembler users, please use .PC $0900, DASM users, use PROCESSOR 6502 and ORG $0900 sei lda #$00 sta $d020 ; have a black sta $d021 ; screen+border sta anim ;What we have here as usual are the ;sprite's own priorities. You already ;should know this part :o)) lda #$ff ; sta $d015 ; All sprites on sta $d01c ; Multicolour on sta $d01b ; Behind chars lda #$05 sta $d025 ;Spr. mcolour 1 lda #$0b sta $d026 ;Spr. mcolour 2 lda #$0d sta $d027 ;Changable colours sta $d028 sta $d029 sta $d02a sta $d02b sta $d02c sta $d02d sta $d02e ;So then, where is the $07f8 pointers, ;etc for the sprites? Well, this time ;they are stored in a loop which is ;called from label SPRITES. Mainly ;because of the sprite's animations. :) ;Position all those sprites ldx #$00 tosprite lda startpos,x sta objpos+$00,x inx cpx #$10 bne tosprite ;Initialise both messages for the demo, ;so when the main loop of the demo plays ;the scroll texts are all refreshed. lda #message1 sta read1+1 stx read1+2 lda #message2 sta read2+1 stx read2+2 ;Set up the colour data for the bitmap ;logo ldx #$00 ;You should already pastecol lda $5800,x ;remember what this sta $d800,x ;does. It simply lda $5900,x ;copies data from sta $d900,x ;$5800 and paste it lda $5a00,x ;into the colour sta $da00,x ;RAM. We fill the lda $5ae8,x ;whole colour RAM sta $dae8,x ;from the pic's inx ;colour datas. bne pastecol ldx #$00 ;I think you clearscr lda #$20 ;already know how sta $0400,x ;this works. The sta $0500,x ;screen gets sta $0600,x ;cleared. Simply sta $06e8,x ;better than using inx ;JSR $E544 :o)) bne clearscr; ;Paste the still message from $4d00 on ;to the screen. ldx #$00 copymsg lda stillmess,x sta $05e0,x inx bne copymsg ;Initialized the main IRQ routines lda #irq1 ;to do first ldy #$00 ;interrupt and write sta $0314 ;to $0314+$0315 stx $0315 ;Initilize the $d012 sty $d012 ;value lda #$1b ldx #$01 ;Turn screen on ldy #$7f ;and turn on $d01a sta $d011 ;so that irqs will stx $d01a ;work continuously sty $dc0d ; lda #$00 tax tay jsr $1000 ;Init music, yeah! cli ;Clear interrupt ;Synchronise routines so we can have ;multiple loops outside of the IRQ ;playing routine mainloop lda sync ;init sync and #$00 sta sync syncwait cmp sync beq syncwait jsr scroll1 ;Call scroll 1 jsr scroll2 ;Call scroll 2 jsr colwash ;Call colwash jsr movepic ;Call movepic jsr sprites ;Call sprites jmp mainloop ;The main IRQ interrupts and raster ;splits. irq1 inc $d019 ;This split is for lda #$86 ;displaying the sta $d012 ;logo, which will ldx #$3b ;be moving left & ldy #$78 ;right slighly so, stx $d011 ;we call the label sty $d018 ;d016 to $d016 lda #$00 ldx #$02 ;Bank 2 at $dd00 sta $d020 sta $d021 stx $dd00 lda d016 ;Check label d016 ora #$10 ;Make $d016 multicol sta $d016 ;paste to $d016 lda #irq2;Call second IRQ sta $0314 ; stx $0315 ; jmp $ea81 irq2 inc $d019 ;Split for normal lda #$da ;screen with charset sta $d012 ;at $2800 lda #$1b ldx #$08 ldy #$1a sta $d011 stx $d016 sty $d018 ldx #$03 ;Bank 3 at $DD00 stx $dd00 lda #irq3 sta $0314 stx $0315 jmp $ea81 irq3 inc $d019 ;This split for lda #$e6 ;the first scroll sta $d012 lda #$1b ldx smooth1 stx $d016 lda #$00 lda #irq4 sta $0314 stx $0315 jmp $ea81 irq4 inc $d019 ;This split for the lda #$fa ;last scroll sta $d012 ldx smooth2 stx $d016 lda #irq1 sta $0314 stx $0315 inc sync jsr $1003 jmp $ea31 ;Now let's make some scroll texts. I ;wont explain what the scroll1 and ;scroll2 routines do, as you should have ;already knew about those in the past ;chapters of this tutorial. ;Scroll text 1 scroll1 lda smooth1 sec sbc #$02 and #$07 sta smooth1 bcs endscr1 ldx #$00 wrap lda $0749,x sta $0748,x inx cpx #$28 bne wrap read1 lda $076f cmp #$00 bne nowrap1 lda #message1 sta read1+1 stx read1+2 jmp read1 nowrap1 sta $076f inc read1+1 lda read1+1 cmp #$00 bne endscr1 inc read1+2 endscr1 rts scroll2 lda smooth2 sec sbc #$03 and #$07 sta smooth2 bcs endscr2 ldx #$00 wrap2 lda $0799,x sta $0798,x inx cpx #$28 bne wrap2 read2 lda $07bf cmp #$00 bne nowrap2 lda #message2 sta read2+1 stx read2+2 jmp read2 nowrap2 sta $07bf inc read2+1 lda read2+1 cmp #$00 bne endscr2 inc read2+2 endscr2 rts ;This is the simple colour washing/roll ;over chars routine. Where the colours ;are moving from the right to the left. colwash lda colours1+$00 sta colours1+$28 lda colours2+$00 sta colours2+$28 ldx #$00 wshloop lda colours1+$01,x sta colours1+$00,x lda colours2+$01,x sta colours2+$00,x lda colours1+$00,x sta $db48,x lda colours2+$00,x sta $db98,x ;You might have noticed here, this is ;where we don't use colour washing, but ;the nice looking colour flash routine ;which is for the text. Just remove ;,x from colours, and you get flashing lda colours1+$00 ;Read colours sta $d9e0,x lda colours1+$00 sta $da08,x lda colours1+$04 sta $da30,x lda colours1+$00 sta $da58,x lda colours1+$08 sta $da80,x inx cpx #$28 bne wshloop rts ;This is another simple routine for ;making the picture move slightly when ;we toggle $D016. You wont need much ;help here, as it is exactly the same ;method as the colour washing technique movepic lda d016+$00 sta d016+$49 ldx #$00 waveloop lda d016+$01,x sta d016+$00,x inx cpx #$49 bne waveloop rts ;Our combine sprites routine sprites ldx #$00 ;You should expand lda objpos+$01,x ;know this sta $d001,x ;already as it lda objpos+$00,x ;has been asl a ;shown before ror $d010 sta $d000,x lda objpos,x ;... and this clc adc xspeed,x sta objpos,x inx inx cpx #$10 bne expand ldx anim ;And this as lda frame,x ;well, where sta $07f8 ;we animate sta $07f9 ;those sprites sta $07fa sta $07fb sta $07fc sta $07fd sta $07fe sta $07ff inx cpx #$28 beq reset inc anim rts reset ldx #$00 stx anim rts ;Data tables for everything ;DASM users, use dc.b instead of byte, ACME users, use !byte instead of .byte colours1 !byte $0b,$0b,$09,$09,$02 !byte $02,$08,$08,$0a,$0a !byte $0f,$0f,$07,$07,$01 !byte $01,$01,$01,$01,$01 !byte $07,$07,$0f,$0f,$08 !byte $08,$02,$02,$09,$09 !byte $0b,$0b,$0b,$0b,$0b !byte $0b,$0b,$0b,$0b,$0b !byte $00 colours2 !byte $0b,$0b,$0b,$0b,$06 !byte $06,$04,$04,$0e,$0e !byte $05,$05,$0d,$0d,$07 !byte $07,$01,$01,$07,$07 !byte $0d,$0d,$0e,$0e,$04 !byte $04,$06,$06,$0b,$0b !byte $0b,$0b,$0b,$0b,$0b !byte $0b,$0b,$0b,$0b,$0b !byte $00 d016 !byte $00,$00,$01,$01,$02 !byte $02,$03,$03,$04,$04 !byte $05,$05,$06,$06,$07 !byte $07,$06,$06,$05,$05 !byte $04,$04,$03,$03,$02 !byte $02,$01,$01,$00,$00 !byte $01,$01,$01,$02,$02 !byte $02,$03,$03,$03,$04 !byte $04,$04,$05,$05,$05 !byte $06,$06,$06,$07,$07 !byte $07,$06,$06,$06,$05 !byte $05,$05,$04,$04,$04 !byte $03,$03,$03,$02,$02 !byte $02,$01,$01,$01,$00 !byte $00,$00,$00 startpos !byte $00,$88 ;Sprite 1 x,y position table !byte $80,$90 ;Sprite 2 x,y " !byte $00,$98 ;Sprite 3 x,y " !byte $80,$a0 ;Sprite 4 x,y " !byte $00,$a8 ;Sprite 5 x,y " !byte $80,$b0 ;Sprite 6 x,y " !byte $00,$b8 ;Sprite 7 x,y " !byte $80,$c0 ;Sprite 8 x,y " xspeed !byte $01,$00 ;Sprite 1 x,y speed (y = 0) table !byte $03,$00 ; " !byte $02,$00 ; " !byte $04,$00 ; " !byte $03,$00 ; " !byte $01,$00 ; " !byte $04,$00 ; " !byte $02,$00 ; " frame !byte $80,$80,$80,$80,$80 !byte $81,$81,$81,$81,$81 !byte $82,$82,$82,$82,$82 !byte $83,$83,$83,$83,$83 !byte $84,$84,$84,$84,$84 !byte $83,$83,$83,$83,$83 !byte $82,$82,$82,$82,$82 !byte $81,$81,$81,$81,$81 ;Remember to extract the data files from your D64 ;image, into the same folder where your code ;is and then import it into the source. ;(Extract and rename ;the prg files that are on your disk into the same ;folder which you have put the source code) ;Insert music here * = $1000 ;Use -2 if source is .PRG from the .D64 ;otherwise the assembler loads the data ;at $1002 instead. Weird, but true. !binary "bin\music.prg",,2 ;Insert sprites into source code * = $2000 !binary "bin\sprites.prg",,2 ;Insert charset into source code * = $2800 !binary "bin\charset.prg",,2 ;Insert scrolltext 1 into source code * = $4000 !binary "bin\scroll1.prg",,2 ;Insert scrolltext 2 into source code * = $4800 !binary "bin\scroll2.prg",,2 ;Insert still text here * = $4d00 !ct scr !text " the new dimension " !text " " !text " http://tnd64.unikat.sk " !text " " !text " assemble it demo " ;Insert picture colour RAM data here * = $5800 !binary "bin\b.logo.prg",,2