.feature c_comments .include "../../build/loadersymbols-c64.inc" .ZEROPAGE .org $10 bmp_delay: .res 1 bmp_addr: .res 2 bmp_ptr: .res 2 scr_ptr_lo: .res 1 scr_ptr: .res 2 cram_ptr: .res 2 chr_count: .res 1 vbl: .res 1 frame: .res 1 cur_frame: .res 1 frame_delay: .res 1 frame_until: .res 1 text_ptr: .res 2 aart_lz_buffer := $fd00 .include "lz_zp.asm" .segment "CODE" ZP=$e0 offset = ZP+0 ZX0_src = ZP+2 ZX0_dst = ZP+4 bitr = ZP+6 pntr = ZP+7 .org $080d jsr install sei lda #$35 sta $01 ldx #fontname jsr loadraw lda #$34 sta $01 ldx #0 : lda $e000, x sta $d800, x lda $e100, x sta $d900, x inx bne :- lda #0 tax : .repeat 4, I sta $d000+(I*250), x .endrepeat inx cpx #250 bne :- lda #$35 sta $01 lda #0 sta ZX0_dst+0 ldx #badguy jsr loadraw lda #0 sta ZX0_src lda #$e0 sta ZX0_src+1 lda #0 sta ZX0_dst lda #$20 jsr zx02 lda #127 sta $dc0d and $d011 sta $d011 lda $dc0d lda $dd0d lda #irq_badguy sta $ffff lda #$1b sta $d011 lda #$d0 sta $d012 lda #1 sta $d01a sta bmp_delay jsr init_bmp lda #0 sta vbl cli ;lda #64 ;sta frame_delay ;jsr wait_loop lda #0 jsr sfx_init lda #7 sta frame_until jsr wait_frame_until lda #64 sta frame_delay jsr wait_loop lda #1 jsr sfx_init ldx #darmtower_txt jsr upload_text lda #50*5 sta frame_delay jsr wait_loop ldx #empty_txt jsr upload_text lda #$0d sta frame_until jsr wait_frame_until ldx #adol_win jsr upload_text lda #50*5 sta frame_delay jsr wait_loop ldx #too_bad_txt jsr upload_text lda #50*5 sta frame_delay jsr wait_loop ldx #empty_txt jsr upload_text lda #$13 sta frame_until jsr wait_frame_until lda #0 jsr sfx_init lda #$1a sta frame_until jsr wait_frame_until jmp * wait_loop: loop2: lda vbl beq loop2 lda #0 sta vbl jsr sfx_play dec frame_delay lda frame_delay beq :+ jmp loop2 : rts wait_frame_until: loop: lda vbl beq loop lda #0 sta vbl lda cur_frame cmp #2 bcc :+ jsr sfx_play : dec bmp_delay bpl :+ jsr update_bmp : lda cur_frame cmp frame_until beq :+ jmp loop : rts init_bmp: lda #$3b sta $d011 lda #$19 sta $d018 lda #$d8 sta $d016 lda $4710 lsr lsr lsr lsr sta $d020 lda $4710 and #$0f sta $d021 lda #0 sta cur_frame sta bmp_delay lda #$11 sta bmp_addr lda #$47 sta bmp_addr+1 ldx #0 : .repeat 4, I lda $3f40+(I*250), x sta $400+(I*250), x lda $4328+(I*250), x sta $d800+(I*250), x .endrepeat inx cpx #250 bne :- rts inc_bmp_addr: inc bmp_addr bne :+ inc bmp_addr+1 : rts update_bmp: ldy #0 sty scr_ptr sty cram_ptr lda (bmp_addr), y jsr inc_bmp_addr sta chr_count cmp #0 ; tfw flags update in inc_bmp_addr bne @skip_frame_end lda (bmp_addr), y jsr inc_bmp_addr sta bmp_delay inc cur_frame rts @skip_frame_end: lda (bmp_addr), y sta bmp_ptr iny lda (bmp_addr), y clc adc #$20 sta bmp_ptr+1 iny lda (bmp_addr), y sta scr_ptr_lo iny lda (bmp_addr), y clc adc #$04 sta scr_ptr+1 clc adc #$d8-$04 sta cram_ptr+1 ldy #0 lda bmp_addr clc adc #4 sta bmp_addr bcc :+ inc bmp_addr+1 : ldx #0 @loop: ldy #0 lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y iny lda (bmp_addr), y sta (bmp_ptr), y lda bmp_ptr clc adc #8 sta bmp_ptr bcc :+ inc bmp_ptr+1 : lda bmp_addr clc adc #8 sta bmp_addr bcc :+ inc bmp_addr+1 : ldy #0 lda (bmp_addr), y ldy scr_ptr_lo sta (scr_ptr), y ldy #1 lda (bmp_addr), y ldy scr_ptr_lo sta (cram_ptr), y inc scr_ptr_lo bne :+ inc scr_ptr+1 inc cram_ptr+1 : lda bmp_addr clc adc #2 sta bmp_addr bcc :+ inc bmp_addr+1 : dec chr_count ldx chr_count bne @loop jmp update_bmp irq_badguy: pha txa pha tya pha inc vbl ;inc $d020 lda #$1b sta $d011 lda #$19 sta $d018 lda #$c8 sta $d016 lda $dd00 and #3 sta @dd00_arc+1 lda #0 sta $dd00 lda #$47 sta $d018 : lda $d012 cmp #$fb bcc :- .res 2, $ea lda #$3b sta $d011 lda #$19 sta $d018 lda #$d8 sta $d016 @dd00_arc: lda #0 sta $dd00 ;dec $d020 asl $d019 pla tay pla tax pla rti badguy: .byte "badguy",0 fontname: .byte "font",0 darmtower_txt: .res (40-26)/2, ' ' .byte "who silenced darm's tower?" .res (40-26)/2, ' ' empty_txt: .res 40, ' ' adol_win: .res (40-20)/2, ' ' .byte "adol must have won.." .res (40-20)/2, ' ' too_bad_txt: .res (40-10)/2, ' ' .byte "too bad..." .res (40-10)/2, ' ' upload_text: lda #$34 sta $01 stx text_ptr sty text_ptr+1 ldy #39 : lda (text_ptr), y sec sbc #$20 sta $d348+40, y dey bne :- lda #$35 sta $01 lda #1 ldy #39 : sta $db48+40, y dey bne :- rts .include "sfx.asm" .include "zx02.asm" .include "thcmod_lz.asm" .res loadraw - * .incbin "../../build/loader-c64.prg", 2 .res install - * .incbin "../../build/install-c64.prg", 2