diff --git a/loader/samples/minexample/minexample.s b/loader/samples/minexample/minexample.s index a0d6c53..e109807 100644 --- a/loader/samples/minexample/minexample.s +++ b/loader/samples/minexample/minexample.s @@ -562,7 +562,7 @@ part_9: ; $2000-$3fff buffer 0 bitmap ; $4000-$5fff buffer 1 bitmap ; $6000-$63ff buffer 1 tilemap - ; $6400-$67ff next buffer CRAM + ; $6400-$6417 next buffer CRAM ; $7000-$77ff tileset bitmap ; $7800-$78ff tileset tile colors ; $7900-$79ff tileset CRAM colors @@ -604,17 +604,52 @@ part_9: ldx temp+1 dex bpl :- - + lda #0 + sta cram_ptr + lda #$64 + sta cram_ptr+1 : - lda #2 - sta frame_delay - jsr wait_loop_2x - lda frame - and #7 - ora #$38 + lda $d011 + bpl :- + lda #$38 sta $d011 + lda #3 + sta timer_mode +@loop: + lda #0 + sta vbl + lda frame + and #1 + tax + jsr copybuf + jsr drawrow +: + lda vbl + cmp #32 + bcc :- + ; B U M R U S H C R A M C O P Y F U N K + ldy #23 +: .repeat 16, I + lda $d808+(19-I)*40,y + sta $d808+(20-I)*40,y + .endrepeat + lda $6400,y + sta $d808+4*40,y + dey + bpl :- inc frame - jmp :- + lda frame + lsr a + lda #$38 + ldx #3 + bcc :+ + lda #$80 + ldx #2 +: + sta $d018 + stx $dd00 + jmp @loop +@finish: jmp * drawrow: @@ -829,7 +864,7 @@ irq_music: lda $dd00 and #3 sta @dd00_arc+1 - lda #3 + and #3 sta $dd00 inc vbl @@ -879,6 +914,18 @@ irq_music: lda #1 sta timer_reached : + lda timer_mode + cmp #3 + bne @timer_done + lda vbl + lsr a + bcs @timer_done + lsr a + and #7 + ora #$38 + sta $d011 + +@timer_done: @dd00_arc: lda #0 @@ -1370,6 +1417,81 @@ load_8000_zx02: pla jmp zx02 +copybuf: + lda @bsrclo,x + sta bmp_addr + lda @bsrchi,x + sta bmp_addr+1 + lda @bdstlo,x + sta bmp_ptr + lda @bdsthi,x + sta bmp_ptr+1 + lda @tsrclo,x + sta text_ptr + lda @tsrchi,x + sta text_ptr+1 + lda @tdstlo,x + sta scr_ptr + lda @tdsthi,x + sta scr_ptr+1 + ldx #16 +@loop: + ldy #23 +: lda (text_ptr),y + sta (scr_ptr),y + dey + bpl :- + ldy #191 +: lda (bmp_addr),y + sta (bmp_ptr),y + dey + bne :- + lda (bmp_addr),y + sta (bmp_ptr),y + ; math dumb cpu be struggling a lot here + lda text_ptr + sec + sbc #40 + sta text_ptr + bcs :+ + dec text_ptr+1 +: + lda scr_ptr + sec + sbc #40 + sta scr_ptr + bcs :+ + dec scr_ptr+1 +: + lda bmp_addr + sec + sbc #<320 + sta bmp_addr + bcs :+ + dec bmp_addr+1 +: + dec bmp_addr+1 + lda bmp_ptr + sec + sbc #<320 + sta bmp_ptr + bcs :+ + dec bmp_ptr+1 +: + dec bmp_ptr+1 + dex + bne @loop + rts + +@bsrclo: .lobytes (15+4)*320+$2040, (15+4)*320+$4040 +@bsrchi: .hibytes (15+4)*320+$2040, (15+4)*320+$4040 +@bdstlo: .lobytes (16+4)*320+$4040, (16+4)*320+$2040 +@bdsthi: .hibytes (16+4)*320+$4040, (16+4)*320+$2040 +@tsrclo: .lobytes (15+4)*40+$0c08, (15+4)*40+$6008 +@tsrchi: .hibytes (15+4)*40+$0c08, (15+4)*40+$6008 +@tdstlo: .lobytes (16+4)*40+$6008, (16+4)*40+$0c08 +@tdsthi: .hibytes (16+4)*40+$6008, (16+4)*40+$0c08 + story_writ: .res 11, ' ' .byte "story written by"