mirror of
https://github.com/actraiser/dust-tutorial-c64-first-intro.git
synced 2025-06-18 17:05:34 -04:00
Initial Commit
This commit is contained in:
parent
e4229681d7
commit
bb0d87197d
BIN
build/hello_world.prg
Normal file
BIN
build/hello_world.prg
Normal file
Binary file not shown.
24
code/data_colorwash.asm
Normal file
24
code/data_colorwash.asm
Normal file
@ -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
|
6
code/data_static_text.asm
Normal file
6
code/data_static_text.asm
Normal file
@ -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 "
|
||||
|
22
code/init_clear_screen.asm
Normal file
22
code/init_clear_screen.asm
Normal file
@ -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
|
14
code/init_static_text.asm
Normal file
14
code/init_static_text.asm
Normal file
@ -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
|
4
code/load_resources.asm
Normal file
4
code/load_resources.asm
Normal file
@ -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
|
42
code/main.asm
Normal file
42
code/main.asm
Normal file
@ -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 ; point IRQ Vector to our custom irq routine
|
||||
ldx #>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
|
3
code/setup_symbols.asm
Normal file
3
code/setup_symbols.asm
Normal file
@ -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
|
36
code/sub_colorwash.asm
Normal file
36
code/sub_colorwash.asm
Normal file
@ -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
|
6
code/sub_music.asm
Normal file
6
code/sub_music.asm
Normal file
@ -0,0 +1,6 @@
|
||||
;============================================================
|
||||
; play music directive
|
||||
;============================================================
|
||||
|
||||
play_music jsr sid_play
|
||||
rts
|
69
index.asm
Normal file
69
index.asm
Normal file
@ -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"
|
BIN
resources/jeff_donald.sid
Normal file
BIN
resources/jeff_donald.sid
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user