FEATURES {
STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0002, size = $001A, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size = $D000 - %S;
sound: start = $7e82, size = $217e, define = yes, file = %O;
}
SEGMENTS {
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw, optional = yes;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = MAIN, type = bss, optional = yes;
ZEROPAGE: load = ZP, type = zp, optional = yes;
SOUND: load = sound, type = rw;
}
Alles anzeigen
;cl65 -o sid2.prg --start-addr $0810 -t c64 -C c64-asm2.cfg sid2.s
.charmap $41,$01 ;A
.charmap $42,$02 ;B
.charmap $43,$03 ;C
.charmap $44,$04 ;D
.charmap $45,$05 ;E
.charmap $46,$06 ;F
.charmap $47,$07 ;G
.charmap $48,$08 ;H
.charmap $49,$09 ;I
.charmap $4a,$0a ;J
.charmap $4b,$0b ;K
.charmap $4c,$0c ;L
.charmap $4d,$0d ;M
.charmap $4e,$0e ;N
.charmap $4f,$0f ;O
.charmap $50,$10 ;P
.charmap $51,$11 ;Q
.charmap $52,$12 ;R
.charmap $53,$13 ;S
.charmap $54,$14 ;T
.charmap $55,$15 ;U
.charmap $56,$16 ;V
.charmap $57,$17 ;W
.charmap $58,$18 ;X
.charmap $59,$19 ;Y
.charmap $5a,$1a ;Z
;.segment "SOUND"
;.incbin "Comic_Bakery.sid"
.org $0810 ;2064
.code
lda #$00
tax
tay
jsr $7f00 ;init address of sid file
sei
lda #$7f ;disable cia1, cia 2 and vic interrupts (timer, keyboard)
sta $dc0d
sta $dd0d
lda #$01 ;enable raster interrupts
sta $d01a
lda #$1b ;enter text mode
sta $d011
ldx #$08 ;use single color
stx $d016
ldy #$14 ;screen ram at $0400, standard charset
sty $d018
lda #<irq ;change irq vector
ldx #>irq
sta $0314
stx $0315
ldy #$00 ;interrupt trigger scan line
sty $d012
lda $dc0d ;clear pending interrupts (cia1, cia2, vic)
lda $dd0d ;read access is sufficient for clearing
asl $d019
cli
;-------------------------------------------------------------------------------
jsr clrScreen ;jsr $e544 zerstört den Sound IRQ!!!
ldx #$17 ;Schleifenzähler (20 Zeichen)
print: ;Schreibe Text
lda text,x
sta $0480,x
dex
bpl print
;-------------------------------------------------------------------------------
lda #$ff
loop:
sta $d020
ldx #$00
ldy #$00
w8:
dey
bne w8
dex
bne w8
sta $fb
dec $fb
lda #$00 ; Lade 0 in den Akku
sta $dc00 ; Schreibe 0 in cia-a für Tastaturabfrage
lda $dc01 ;Lade cia-b Inhalt in Akku und vergleiche auf 255
cmp #$ff
bne exit
jmp go_on ;wenn ja keine Taste gedrückt mach weiter
exit:
lda #$06 ;hellblau
sta $D021 ;für Rahmen
lda #$0e ;dunkelblau
sta $D020 ;für Hintergrund
lda #$0e ;hellblau
sta $0286 ;für Schrift
jsr clrScreen ;lösche BS
rts
;-------------------------------------------------------------------------------
go_on:
lda $fb
jmp loop
;-------------------------------------------------------------------------------
clrScreen:
ldx #$00 ;Schleifenzähler (256 Zeichen je Page)
lda #' ' ;alles mit Leerzeichen füllen
@loop:
sta $0400,X ;1. Page des BSSpeichers
sta $0500,X ;2. Page
sta $0600,X ;3. Page
sta $06E8,X ;4. Page (24 wegen der SpriteRegister)
dex ;Schleifenzähler verringern
bne @loop ;Solange größer 0 > @loop
rts
;-------------------------------------------------------------------------------
irq:
jsr $7f03 ;sid file play address
asl $d019 ;ACK interrupt and prevent from re-starting after exit
jmp $ea81
text:
.asciiz "SID DEMO BY BYTEBREAKER."
.res $7e82-*
.incbin "Comic_Bakery.sid"
Alles anzeigen
Klappen tut es nur mit
.org
.code
(...)
.res
.incbin
und man MUSS die Basic Zeile auf $810 setzen. Bei $801 klappt es nicht (siehe erste auskommentierte Zeile. Man startet dann mit sys 2064. Ich weiß nicht warum nur $810 klappt - das mit $810 stand in einem Tutorial für einen IRQ-gestützten SID-File-Player schon fest. Ich habe nur das SID-File, die Adressen im SID-File geändert und das Geschehen drumherum ergänzt.
Der C64 spielt das Stück ab, wechselt die Rahmenfarbe (langsam) und es steht Text auf dem zuvor gelöschten Bildschirm - den ich mit einer eigenen Routine löschen muss, denn die ROM-Routine macht den IRQ (warum auch immer) kaputt.
.segment und .incbin, wie es "fortschrittlich" sein muss, sind im Sourced auskommentiert weil ich nicht weiß wie ich es mit diesen Direktiven zum Laufen bringen soll.
Edit:
Hier Ulrich v. Bassewitzs Erklärung zum Incbin/Segment-Thema:
Please note that it is your job to make sure the resulting data is loaded to$5000. Anything the linker will do for you is to relocate the data in thesegment named "SOUND" to the address $5000 and write it to the given file. Forexample, if you just have this segment in your config file, and then load theresulting binary to $1000, it won't work. While the linker can prepare thedata so it is able to run at the given address, it cannot load it to thataddress. The standard setup for the C64 is to load the generated program at$801 (the BASIC start). The linker is used to relocate the data for thisaddress, and the startup code will take all necessary steps to initialize allnecessary stuff so the program can run. If you want something special (likeloading something to $5000), you will have to do that yourself.
Das Zitat ist verlinkt, da steht dann auch der Rest drin.