diff --git a/build/hello_world.prg b/build/hello_world.prg new file mode 100644 index 0000000..2dbe978 Binary files /dev/null and b/build/hello_world.prg differ diff --git a/code/data_colorwash.asm b/code/data_colorwash.asm new file mode 100644 index 0000000..a9d1813 --- /dev/null +++ b/code/data_colorwash.asm @@ -0,0 +1,24 @@ +; color data table +; first 9 rows (40 bytes) are used for the color washer +; on start the gradient is done by byte 40 is mirroed in byte 1, byte 39 in byte 2 etc... + +color !byte $09,$09,$02,$02,$08 + !byte $08,$0a,$0a,$0f,$0f + !byte $07,$07,$01,$01,$01 + !byte $01,$01,$01,$01,$01 + !byte $01,$01,$01,$01,$01 + !byte $01,$01,$01,$07,$07 + !byte $0f,$0f,$0a,$0a,$08 + !byte $08,$02,$02,$09,$09 + !byte $00,$00,$00,$00,$00 + !byte $00 + +color2 !byte $09,$09,$02,$02,$08 + !byte $08,$0a,$0a,$0f,$0f + !byte $07,$07,$01,$01,$01 + !byte $01,$01,$01,$01,$01 + !byte $01,$01,$01,$01,$01 + !byte $01,$01,$01,$07,$07 + !byte $0f,$0f,$0a,$0a,$08 + !byte $08,$02,$02,$09,$09 + !byte $09 \ No newline at end of file diff --git a/code/data_static_text.asm b/code/data_static_text.asm new file mode 100644 index 0000000..6501a26 --- /dev/null +++ b/code/data_static_text.asm @@ -0,0 +1,6 @@ + +; the two lines of text for color washer effect + +line1 !scr " actraiser in 2013 presents... " +line2 !scr " example effect for dustlayer tutorials " + diff --git a/code/init_clear_screen.asm b/code/init_clear_screen.asm new file mode 100644 index 0000000..cd8eb45 --- /dev/null +++ b/code/init_clear_screen.asm @@ -0,0 +1,22 @@ +;============================================================ +; clear screen +; a loop instead of kernal routine to save cycles +;============================================================ + +init_screen ldx #$00 ; start of loop + stx $d021 ; border + stx $d020 ; background + +clear lda #$20 ; #$20 is the spacebar screencode + sta $0400,x ; fill four areas with 256 spacebar characters + sta $0500,x + sta $0600,x + sta $06e8,x + lda #$0c ; puts into the associated color ram dark grey ($0c)... + sta $d800,x ; and this will become color of the scroll text + sta $d900,x + sta $da00,x + sta $dae8,x + inx + bne clear + rts \ No newline at end of file diff --git a/code/init_static_text.asm b/code/init_static_text.asm new file mode 100644 index 0000000..a1a6d96 --- /dev/null +++ b/code/init_static_text.asm @@ -0,0 +1,14 @@ +;============================================================ +; write the two line of text to screen center +;============================================================ + + +init_text lda line1,x ; read characters from line1 table of text... + sta $0590,x ; ...and store in screen ram near the center + lda line2,x ; read characters from line1 table of text... + sta $05e0,x ; ...and put 2 rows below line1 + + inx + cpx #$28 ; finished when all 40 cols of a line are processed + bne init_text + rts \ No newline at end of file diff --git a/code/load_resources.asm b/code/load_resources.asm new file mode 100644 index 0000000..c94011f --- /dev/null +++ b/code/load_resources.asm @@ -0,0 +1,4 @@ +; load sid music + +* = address_music ; address to load the music data +!bin "resources/jeff_donald.sid",, $7c+2 ; remove header from sid and cut off original loading address diff --git a/code/main.asm b/code/main.asm new file mode 100644 index 0000000..539007b --- /dev/null +++ b/code/main.asm @@ -0,0 +1,42 @@ +;============================================================ +; some initialization and interrupt redirect setup +;============================================================ + + sei ; set interrupt disable flag + + jsr init_screen ; clear the screen + jsr init_text ; write lines of text + jsr sid_init ; init music routine now + + ldy #$7f ; $7f = %01111111 + sty $dc0d ; Turn off CIAs Timer interrupts ($7f = %01111111) + sty $dd0d ; Turn off CIAs Timer interrupts ($7f = %01111111) + lda $dc0d ; by reading $dc0d and $dd0d we cancel all CIA-IRQs in queue/unprocessed + lda $dd0d ; by reading $dc0d and $dd0d we cancel all CIA-IRQs in queue/unprocessed + + lda #$01 ; Set Interrupt Request Mask... + sta $d01a ; ...we want IRQ by Rasterbeam (%00000001) + + lda #irq + sta $314 ; store in $314/$315 + stx $315 + + lda #$00 ; trigger first interrupt at row zero + sta $d012 + + cli ; clear interrupt disable flag + jmp * ; infinite loop + + +;============================================================ +; custom interrupt routine +;============================================================ + +irq dec $d019 ; acknowledge IRQ / clear register for next interrupt + + jsr colwash ; jump to color cycling routine + jsr play_music ; jump to play music routine + + + jmp $ea81 ; return to kernel interrupt routine \ No newline at end of file diff --git a/code/setup_symbols.asm b/code/setup_symbols.asm new file mode 100644 index 0000000..35a3c80 --- /dev/null +++ b/code/setup_symbols.asm @@ -0,0 +1,3 @@ +address_music = $1000 ; loading address for sid tune +sid_init = $1000 ; init routine for music +sid_play = $1006 ; play music routine \ No newline at end of file diff --git a/code/sub_colorwash.asm b/code/sub_colorwash.asm new file mode 100644 index 0000000..45f2ae2 --- /dev/null +++ b/code/sub_colorwash.asm @@ -0,0 +1,36 @@ +;============================================================ +; color washer routine +;============================================================ + + +; during the control of the color washing routine, +; we take the byte, which is at color+00 and then +; we place it at color+$28, then we call a continuous loop +; which makes the data table cycle by subtracting each piece of data in the data table by one +; and read the calculations 40 times ($28). Therefore the data table pulls each byte of data. +; Also inside our loop, the colors are read from the data table and put into color RAM, +; which starts at $D800. + +colwash lda color+$00 ; load first color + sta color+$28 ; store in column 40 ($28 = #40) - this resets the table for the next color cycle + sta $d9df,x + ldx #$00 ; init loop +cycle1 lda color+$01,x ; CYCLE iterates once(!) by moving color by 1 in table + sta color+$00,x + lda color,x ; load current color + sta $d990,x ; put into color ram for one of the 40 positions + inx ; inc iterator + cpx #$28 ; have we done 40 iterations yet? + bne cycle1 ; if no, continue + +colwash2 lda color2+$28 ; load last color + sta color2+$00 ; store in column 00 this resets the table for the next color cycle + ldx #$28 +cycle2 lda color2-$01,x ; CYCLE iterates once(!) by moving color by 1 in table in reverse order + sta color2+$00,x + lda color2,x ; load current color + sta $d9df,x ; put into color ram for one of the 40 positions + dex ; decrease iterator + bne cycle2 ; if x not zero yet, continue + + rts ; return \ No newline at end of file diff --git a/code/sub_music.asm b/code/sub_music.asm new file mode 100644 index 0000000..4acecad --- /dev/null +++ b/code/sub_music.asm @@ -0,0 +1,6 @@ +;============================================================ +; play music directive +;============================================================ + +play_music jsr sid_play + rts \ No newline at end of file diff --git a/index.asm b/index.asm new file mode 100644 index 0000000..ba09dc9 --- /dev/null +++ b/index.asm @@ -0,0 +1,69 @@ +;============================================================ +; Example Project for C64 Tutorials from +; Code by actraiser/Dustlayer +; Music: Ikari Intro by Laxity +; +; Simple Colorwash effect with a SID playing +; +; http://www.dustlayer.com +; +;============================================================ + +;============================================================ +; index file which loads all source code and resources files +;============================================================ + +;============================================================ +; specify output file +;============================================================ + +!cpu 6502 +!to "build/hello_world.prg",cbm ; output file + +;============================================================ +; BASIC loader with start address $c000 +;============================================================ + +* = $0801 ; BASIC start address (#2049) +!byte $0d,$08,$dc,$07,$9e,$20,$34,$39 ; BASIC loader to start at $c000... +!byte $31,$35,$32,$00,$00,$00 ; puts BASIC line 2012 SYS 49152 +* = $c000 ; start address for 6502 code + +;============================================================ +; Main routine with IRQ setup and custom IRQ routine +;============================================================ + +!source "code/main.asm" + +;============================================================ +; setup and init symbols we use in the code +;============================================================ + +!source "code/setup_symbols.asm" + +;============================================================ +; tables and strings of data +;============================================================ + +!source "code/data_static_text.asm" +!source "code/data_colorwash.asm" + +;============================================================ +; one-time initialization routines +;============================================================ + +!source "code/init_clear_screen.asm" +!source "code/init_static_text.asm" + +;============================================================ +; subroutines called during custom IRQ +;============================================================ + +!source "code/sub_colorwash.asm" +!source "code/sub_music.asm" + +;============================================================ +; load resource files (for this small intro its just the sid) +;============================================================ + +!source "code/load_resources.asm" \ No newline at end of file diff --git a/resources/jeff_donald.sid b/resources/jeff_donald.sid new file mode 100644 index 0000000..aa43708 Binary files /dev/null and b/resources/jeff_donald.sid differ