diff --git a/loader/samples/minexample/Makefile b/loader/samples/minexample/Makefile index de75bd8..09c063b 100644 --- a/loader/samples/minexample/Makefile +++ b/loader/samples/minexample/Makefile @@ -167,6 +167,7 @@ $(DISKIMAGE): $(ASSEMBLE) $(CC1541) -f "font" -w font.bin \ -f "scrmap" -w tilemap.bin.lz \ -f "intrbmp" -w title_320-prepared.zx0.prg \ + -f "tower" -w tower.zx0.prg \ $@ diff --git a/loader/samples/minexample/conv_zx0.sh b/loader/samples/minexample/conv_zx0.sh index 9f45280..f419899 100644 --- a/loader/samples/minexample/conv_zx0.sh +++ b/loader/samples/minexample/conv_zx0.sh @@ -4,4 +4,7 @@ cat badguy.zx0 >> badguy.zx0.prg python3 aart_lz.py tilemap.bin tilemap.bin.lz zx02/zx02 title_320-prepared.bin title_320-prepared.zx0 printf "\x00\x80" > title_320-prepared.zx0.prg -cat title_320-prepared.zx0 >> title_320-prepared.zx0.prg \ No newline at end of file +cat title_320-prepared.zx0 >> title_320-prepared.zx0.prg +zx02/zx02 tower.bin tower.zx0 +printf "\x00\x80" > tower.zx0.prg +cat tower.zx0 >> tower.zx0.prg \ No newline at end of file diff --git a/loader/samples/minexample/minexample.s b/loader/samples/minexample/minexample.s index f27b3d1..710e064 100644 --- a/loader/samples/minexample/minexample.s +++ b/loader/samples/minexample/minexample.s @@ -16,6 +16,10 @@ cur_frame: .res 1 frame_delay: .res 1 frame_until: .res 1 text_ptr: .res 2 +timer: .res 2 +timer_limit: .res 2 +timer_reached: .res 2 +timer_mode: .res 1 aart_lz_buffer := $fd00 .include "lz_zp.asm" @@ -83,39 +87,6 @@ copy_start: sta $01 jmp CODE_START_ADDR -run_nufli_bmp: - lda #$01 - sta $81 - lda #$29 - sta $80 - lda #0 - sta $d01a - jsr $a000 - cli - jsr $3000 -@loop: - bit $d011 - bpl @loop - jsr $a003 -@loop2: - bit $d011 - bmi @loop2 - lda #0 - sta $d020 - sta $d021 - jsr $a003 - lda $80 - bne :+ - dec $81 -: - dec $80 - lda $81 - cmp #$ff - beq :+ - jmp @loop -: - rts - .res loadraw - * .incbin "../../build/loader-c64.prg", 2 @@ -138,8 +109,12 @@ code_start: : lda $8000, x sta $d800, x + eor #$ff + sta $c00, x lda $8100, x sta $d900, x + eor #$ff + sta $d00, x inx bne :- @@ -205,6 +180,7 @@ code_start: ;sta frame_delay ;jsr wait_loop +/* lda #0 jsr sfx_init @@ -269,6 +245,7 @@ code_start: lda #120 sta frame_delay jsr wait_loop +*/ lda #$0b sta $d011 @@ -291,6 +268,10 @@ code_start: ldy #>sidname jsr loadraw + ldx #towername + jsr loadraw + lda #fake_kernal_irq @@ -302,8 +283,114 @@ code_start: jsr run_nufli_bmp sei jsr init_2x + lda #$0b + sta $d011 + ;ldx #3 +;: + ;jsr wait_frame + ;dex + ;bpl :- + jsr clr_txt + ldx #story_writ + jsr write_txt3 + ldx #$30 + ldy #$01 + jsr init_timer + lda #1 + sta timer_mode + + lda #0 + sta ZX0_src + lda #$80 + sta ZX0_src+1 + lda #0 + sta ZX0_dst + lda #$20 + jsr zx02 + +: + lda timer_reached + beq :- + + ldx #$b8 + ldy #$01 + jsr init_timer + lda #2 + sta timer_mode +: + lda timer_reached + beq :- + + jsr init_bmp + + lda #0 + sta vbl + + lda #$11 + sta frame_until + jsr wait_frame_until_2x + + ldx #$6c +: + jsr wait_frame + jsr wait_frame + dex + bpl :- + + lda #$0b + sta $d011 jmp * + +wait_frame: +@loop: + bit $d011 + bpl @loop +@loop2: + bit $d011 + bmi @loop2 + rts + +story_writ: +.res 11, ' ' +.byte "story written by" +.res 40-(16+11), ' ' +.res 11, ' ' +.res 5, ' ' +.byte "takahiro ohura" +.res 40-(14+11+5), ' ' +.res 11, ' ' +.res 5, ' ' +.byte "tomoo yamane" +.res 40-(12+11+5), ' ' + + +clr_txt: + lda #$80 + ldx #0 +: + .repeat 4, I + sta $400+(I*250), x + .endrepeat + inx + cpx #250 + bne :- + lda #0 + ldx #0 +: + .repeat 4, I + sta $d800+(I*250), x + .endrepeat + inx + cpx #250 + bne :- + lda #$13 + sta $d018 + lda #$1b + sta $d011 + rts + init_2x: lda #127 sta $dc0d @@ -351,6 +438,21 @@ init_2x: cli rts +init_timer: + lda #0 + sta timer_reached + sta timer_mode + sta timer + sta timer+1 + stx timer_limit + sty timer_limit+1 + rts + +fade_cols: + .byte 0, 0 + .byte $0, $0, $0, $0, $b, $c, $f, $1 + .res 32-10, $1 + irq_music: pha txa @@ -358,9 +460,63 @@ irq_music: tya pha - inc $d020 + lda $dd00 + and #3 + sta @dd00_arc+1 + lda #3 + sta $dd00 + + inc vbl + + ;inc $d020 jsr $a003 - dec $d020 + ;dec $d020 + + lda timer_mode + cmp #1 + bne :+ + lda timer+1 + bne :+ + lda timer + lsr + lsr + lsr + tax + lda fade_cols, x + sta $d021 +: + lda timer_mode + cmp #2 + bne :+ + lda timer+1 + bne :+ + lda timer + lsr + lsr + lsr + eor #31 + tax + lda fade_cols, x + sta $d021 +: + + inc timer + bne :+ + inc timer+1 +: + lda timer + cmp timer_limit + bne :+ + lda timer+1 + cmp timer_limit+1 + bne :+ + lda #1 + sta timer_reached +: + +@dd00_arc: + lda #0 + sta $dd00 pla tay @@ -385,9 +541,9 @@ fake_kernal_irq: jmp ($0314) ; fuck you wait_loop: -loop2: +@loop2: lda vbl - beq loop2 + beq @loop2 lda #0 sta vbl @@ -397,14 +553,14 @@ loop2: dec frame_delay lda frame_delay beq :+ - jmp loop2 + jmp @loop2 : rts wait_frame_until: -loop: +@loop: lda vbl - beq loop + beq @loop lda #0 sta vbl @@ -424,12 +580,51 @@ loop: cmp frame_until beq :+ - jmp loop + jmp @loop : rts + +wait_loop_2x: +@loop: + lda vbl + cmp #2 + bcc @loop + + lda #0 + sta vbl + + dec frame_delay + lda frame_delay + beq :+ + jmp @loop +: + rts + +wait_frame_until_2x: +@loop: + lda vbl + cmp #2 + bcc @loop + + lda #0 + sta vbl + + dec bmp_delay + bpl :+ + jsr update_bmp +: + + lda cur_frame + cmp frame_until + beq :+ + jmp @loop +: + rts + + init_bmp: - lda #$3b + lda #$0b sta $d011 lda #$19 sta $d018 @@ -467,6 +662,9 @@ init_bmp: inx cpx #250 bne :- + + lda #$3b + sta $d011 rts inc_bmp_addr: @@ -647,6 +845,7 @@ badguy: .byte "badguy",0 fontname: .byte "font",0 sidname: .byte "sid", 0 introname: .byte "intrbmp", 0 +towername: .byte "tower", 0 darmtower_txt: .res (40-26)/2, ' ' @@ -663,6 +862,48 @@ too_bad_txt: .byte "too bad..." .res (40-10)/2, ' ' +write_txt3: + stx text_ptr + sty text_ptr+1 + + ldx #0 + ldy #0 +: + lda (text_ptr), y + sec + sbc #$20 + ora #$80 + sta $400+10*40, x + iny + inx + cpx #40 + bne :- + + ldx #0 +: + lda (text_ptr), y + sec + sbc #$20 + ora #$80 + sta $400+12*40, x + iny + inx + cpx #40 + bne :- + + ldx #0 +: + lda (text_ptr), y + sec + sbc #$20 + ora #$80 + sta $400+14*40, x + iny + inx + cpx #40 + bne :- + rts + upload_text: lda #$34 sta $01 @@ -690,9 +931,40 @@ upload_text: bne :- rts -.include "sfx.asm" -.include "zx02.asm" -.include "thcmod_lz.asm" + +run_nufli_bmp: + lda #$01 + sta $81 + lda #$29 + sta $80 + lda #0 + sta $d01a + jsr $a000 + cli + jsr $3000 +@loop: + bit $d011 + bpl @loop + jsr $a003 +@loop2: + bit $d011 + bmi @loop2 + lda #0 + sta $d020 + sta $d021 + jsr $a003 + lda $80 + bne :+ + dec $81 +: + dec $80 + lda $81 + cmp #$ff + beq :+ + jmp @loop +: + rts + .res $ea31-*, $ff ;asl $d019 @@ -712,4 +984,8 @@ upload_text: pla rti +.include "sfx.asm" +.include "zx02.asm" +.include "thcmod_lz.asm" + code_end: diff --git a/loader/samples/minexample/tower.bin b/loader/samples/minexample/tower.bin new file mode 100644 index 0000000..5f42779 Binary files /dev/null and b/loader/samples/minexample/tower.bin differ diff --git a/loader/samples/minexample/tower.zx0 b/loader/samples/minexample/tower.zx0 new file mode 100644 index 0000000..4db189b Binary files /dev/null and b/loader/samples/minexample/tower.zx0 differ diff --git a/loader/samples/minexample/tower.zx0.prg b/loader/samples/minexample/tower.zx0.prg new file mode 100644 index 0000000..299e488 Binary files /dev/null and b/loader/samples/minexample/tower.zx0.prg differ