;=================================================== ;Koala Paint Picture + Music Linker ;by Richard Bayliss. ;(C)2018 The New Dimension ;=================================================== musicinit = $1000 ;Initialise address for music player musicplay = $1003 ;Play address for music player gamestart = $080d ;Jump address for exomizer decruncher ;before the game runs. ;Note: ;Bitmap @ $2000-$3f3f ;ScreenRAM @ $3f40-$4327 ;ColourRAM @ $4328-$470f sram = $3f40 ;Picture screen RAM cram = $4328 ;Picture colour RAM bgr = $4710 ;Picture background colour scr = $0400 ;Screen RAM - to write to col = $d800 ;Colour RAM - to write to !to "koalapiclinker.prg",cbm ;Picture displayer test *=$0801 !basic 2064 *=$0810 sei lda #$37 sta $01 lda $02a6 ;Store PAL/NTSC system type sta system ;to system pointer. lda #$0b sta $d011 ;Screen off for a start ;First step for the displayer, clear the entire screen jsr clearscreen lda #$24 ;Self-mod raster start position sta r1+1 lda #$3b ;Self-mod raster end position sta s1+1 lda #$7b ;Self-mod screen type sta s2+1 ;Setup the values for displaying the picture charset, and bank ;memory area. lda #$00 ;Black border sta $d020 lda bgr ;Screen colour from Koala bitmap data sta $d021 lda #$03 ;VIC2 Bank $03 set (Default VIC2 bank) sta $dd00 lda #$18 ;Shared: - Screen Multicolour + HPOS sta $d016 ;and bitmap charset/Screen RAM position sta $d018 lda #$00 ;No sprites sta $d015 ;Fill picture screen with colour and screen RAM data, ;so we have a full bitmap picture on display ldx #$00 buildpicdata lda sram,x ;Fetch the picture's screen RAM data sta scr,x ;store to screen RAM ($0400) lda sram+$100,x sta scr+$100,x lda sram+$200,x sta scr+$200,x lda sram+$2e8,x sta scr+$2e8,x lda cram,x ;Fetch the picture's colour RAM data sta col,x ;store to VIC2 colour RAM. lda cram+$100,x sta col+$100,x lda cram+$200,x sta col+$200,x lda cram+$2e8,x sta col+$2e8,x inx ;256 bytes per segment bne buildpicdata ;Set up interrupts to init + play music lda #irq1 sta $0315 lda #$7f sta $dc0d lda #$00 sta $d012 lda #$3b sta $d011 lda #$01 sta $d01a lda #$00 mp1 jsr musicinit ;Initialise Richard's music cli ;Step 1 - Draw the bitmap in blind down form! loop1 lda #0 ;Synchronize timer first sta sync cmp sync beq *-3 lda r1+1 ;Now check position of self-mod raster split cmp #$fb ;to see if it has reached near to the other raster beq finished_draw ;If it has, indicate end of draw function. inc r1+1 ;Otherwise shift the first raster lower. jmp loop1 ;Drawing has finished. Wait for user input wait_input lda $dc01 ;Check for spacebar being pressed cmp #$ef bne test_fire_joy2 jmp remove_pic ;Space was pressed, remove the picture test_fire_joy2 ;Check for fire button on joy port 2 lda #16 ;NOTE: values 1=Up, 2=Down, 4=Left, 8=Right, 16=Fire bit $dc00 ;Hit fire in port 2? bne wait_input ;Definitely not. Loop wait_input ;Draw the picture out of the screen. Using a raster ;as we did before with transition in. remove_pic lda #$24 sta r1+1 lda #$7b sta s1+1 lda #$3b sta s2+1 lda #0 loop2 sta sync cmp sync beq *-3 lda r1+1 cmp #$f9 beq finished_draw2 inc r1+1 jmp loop2 finished_draw2 jmp rungame ;IRQ1 - Bitmap mode irq1 asl $d019 lda $dc0d sta $dd0d s1 lda #$3b sta $d011 r1 lda #$22 sta $d012 lda #1 sta sync jsr palntscplayer lda #irq2 sta $0315 jmp $ea7e ;IRQ2 - Blank mode irq2 asl $d019 s2 lda #$1b sta $d011 r2 lda #$fc sta $d012 lda #irq1 sta $0315 jmp $ea7e ;Check system clock speed (PAL/NTSC) in order to ;play music at the correct speed as PAL already ;does. palntscplayer lda system cmp #$01 beq pal inc ntsctimer lda ntsctimer cmp #$06 beq notpal pal jsr musicplay rts notpal lda #0 sta ntsctimer rts ;Rungame - Switch off all exsiting interrupts ;erase the screen, and then call relocator and ;run main program! rungame sei lda #$0b sta $d011 lda #$31 sta $0314 lda #$ea sta $0315 destroyall lda #$81 sta $dc0d sta $dd0d lda #$00 sta $d019 sta $d01a sta $d021 jsr clearscreen lda #$1b sta $d011 lda #$14 sta $d018 lda #$08 sta $d016 ldx #$00 silentchip lda #$00 sta $d400,x inx cpx #$18 bne silentchip ldx #$00 copyreloc lda relocator,x sta $0400,x inx bne copyreloc lda #$00 sta $0800 ;cli jmp $0400 ;Main relocator, for moving data from one part of the memory ;to the BASIC startup memory. relocator sei relocloop lda #$35 sta $01 rel1 ldx #$00 rel2 lda $4800,x rel3 sta $0801,x inx bne rel2 inc $0409 inc $040c lda $0409 bne rel1 lda #$37 sta $01 run jmp gamestart ;Subroutine to clear the c64 screen clearscreen ldx #$00 clrscreen lda #$00 sta $0400,x sta $0500,x sta $0600,x sta $06e8,x lda #$00 sta $d800,x sta $d900,x sta $da00,x sta $dae8,x inx bne clrscreen rts system !byte 0 sync !byte 0 ntsctimer !byte 0 *=$1000 !bin "loadertune.prg",,2 *=$2000 !bin "valkyrie3pic.kla",,2 ;Main program will be linked *=$4800 mainprogram !bin "valkyrie3.prg",,2