processor 6502 srcPointer = $b5 dstPointer = $b7 dstPointerEnd = $b9 fake_current_byte = $126 count = $128 org $a000 ; autostart cartridge magic number WORD coldstart WORD coldstart BYTE #$41, #$30, #$c3, #$c2, #$cd coldstart SUBROUTINE cld sei jsr $fd8d ; initialize and test RAM jsr $fd52 ; restore default I/O vectors jsr $fdf9 ; initialize I/O registers jsr $e518 ; initialize hardware cli ; enable interrupts lda $0288 sta $0294 jsr $e45b ; initialize BASIC vector table jsr $e3a4 ; initialize BASIC RAM locations jsr $e404 ; print startup message and initialize memory pointers ldx #$fb ; value for stack start txs ; set stack pointer lda #$76 ; set "READY." pointer ldy #$c3 jsr $cb1e ; print null terminated string lda #$80 ; set for control messages only jsr $ff90 ; control kernal messages .oracopio: jsr copycode .almost_ready: ; set current BASIC line number lda #$ff sta $3a lda #0 sta $3b ; set start of variables lda #<($1001 + demo_end - demo_start) sta $2d lda #>($1001 + demo_end - demo_start) sta $2e jsr clear_color_ram ; print informative message for user lda #message jsr $cb1e ; print null terminated string ; install fake chrin to hijack custom commands sei lda #fake_chrin sta $325 cli jmp $c483 ; BASIC ; custom hijacked command line fake_input_line: BYTE "RUN",#$0d,#0,#0,#0 fake_chrin SUBROUTINE ldy fake_current_byte lda fake_input_line,y iny sty fake_current_byte cpy #5 bne .end_fake_chrin dey sty fake_current_byte .end_fake_chrin: clc rts clear_color_ram SUBROUTINE lda #$02 ldx #$00 .loop: sta $9600,x sta $9700,x dex bne .loop rts ; This routine does a lot of unnecessary things, ; but I added a lot of garbage things to debug it, ; because it did not work as intended. ; In the end, the problem was elsewhere, as usual. copycode SUBROUTINE sei lda #0 sta count sta count + 1 lda #demo_start sta srcPointer + 1 lda #$01 sta dstPointer lda #$10 sta dstPointer + 1 ldy #0 copyloop: lda (srcPointer),y sta (dstPointer),y inc srcPointer bne .noinc1 inc srcPointer + 1 .noinc1: inc dstPointer bne .noinc2 inc dstPointer + 1 .noinc2: inc count bne .noinc3 inc count + 1 .noinc3: ; lenght of program to copy lda count cmp #DEMO_LEN bne copyloop cli .finito: rts message: BYTE #$0d,#$0d,"PLEASE WAIT 20 SEC",#$0d,"I'M JUST",#$0d,"AN OLD COMPUTER",#$0d,#0 ; https://www.commodore.ca/manuals/funet/cbm/vic20/demos.basic/unexpanded/Stillenacht.prg demo_start: .incbin "build/demo.raw" demo_end: DEMO_LEN SET demo_end - demo_start ECHO DEMO_LEN . = $bffc jmp coldstart . = $bfff BYTE #$ff