;6502SDK sample file
;    -----------------------------------------
;   |                                         |
;   |     **** COMMODORE 64 BASIC V2 ****     |
;   |                                         |
;   |  64K RAM SYSTEM  38911 BASIC BYTES FREE |
;   |                                         |
;   |READY.                                   |
;   |                                         |
;    -----------------------------------------
;
; ...do you remember this screen? If you have a C64 and a data transfer cable
; or you use some C64 emulator, you can use 6502SDK to write your own .PRG
; files.
; To try this demo, compile it (ALT-F9) and save the object file in .PRG format,
; from 0801 to 
;

;macro for pause
#macro pause [cycles]
	pha
	txa
	pha
	clc
	lda #$00
	ldx #cycles
loop:	adc #$01
	nop
	nop
	nop
	bne loop
	dex
	bne loop
	pla
	tax
	pla	
#endm

SID = $d400

org $0801    ;start of BASIC area

DB $0C, $08  ; pointer to next line
DB $0A, $00  ; line number (10)
DB $9E       ; SYS token

DB " 2062" ; SYS address in ASCII
DB 0, 0, 0 ; end-of-program

;-----------------------------------------------------
;the machine-code begins here.

;set border and screen to black

	lda #$00
	sta $d020
	sta $d021

; print a zero-ended string: note that CBM code is different
; from ASCII...
;
	lda #<message
	ldy #>message
	jsr $ab1e	;calls a BASIC subroutine

; now, let's make some sound fx :)
	lda #$00
	sta SID
	lda #$40
	sta SID+1
	lda #$00
	sta SID+5
	lda #$f0
	sta SID+6
	lda #$0f
	sta SID+24

	lda #$11
	sta SID+4
	pause[$FF]
	lda #$00
	sta SID+4
	
;returns to BASIC
	rts

;Data
message: db "UPPERCASE and lowercase !@#$%^&", 13, 0

