diff --git a/plat.nes b/plat.nes index 9cc6a38..d33954f 100644 Binary files a/plat.nes and b/plat.nes differ diff --git a/plat.s b/plat.s index 8757f94..d7a251c 100644 --- a/plat.s +++ b/plat.s @@ -277,6 +277,23 @@ level: .byte 0,1,2,3,4,5,6,7,8,9,0,11,11,11,11,11 .byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 +level2: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10 +.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 +.byte 0,1,7,7,7,7,7,7,7,1,0,11,11,11,11,11 +.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 + metatiles: .byte 0,0,0,0,0 .byte $14,$15,$16,$17,1 ; Full block @@ -759,21 +776,14 @@ setup_background: dey bne :-- - lda #0 - sta var_o - @nametable_start: +; ------------- Nametable 1: level lda $2002 - lda #$24 - ldx var_o - cpx #1 - bne :+ - lda #$24 - : + lda #$20 sta $2006 lda #$00 sta $2006 ldy #0 - @row_start: + @row_start_nmt1: ldx #0 : txa @@ -834,7 +844,7 @@ setup_background: bne :- iny cpy #15 - bne @row_start + bne @row_start_nmt1 ; clear attributes @@ -944,14 +954,185 @@ setup_background: iny cpy #8 bne :-- +; ---------------- End nametable 1: Level +; ---------------- Begin nametable 2: Level 2 + lda $2002 + lda #$24 + sta $2006 + lda #$00 + sta $2006 + ldy #0 + @row_start_nmt2: + ldx #0 + : + txa + pha - ldx var_o - cpx #$20 - bne :+ - ldx #$24 - stx var_o - jmp @nametable_start + ; index is (Y * 16) + X + stx temp_x + lda #16 + jsr mul_y + clc + adc temp_x + tax + + lda level2, X + ldx #5 + jsr mul_x + tax + + lda metatiles+0, X + sta $2007 + lda metatiles+1, X + sta $2007 + + pla + tax + inx + cpx #16 + bne :- + + ; again + ldx #0 + : + txa + pha + + ; index is (Y * 16) + X + stx temp_x + lda #16 + jsr mul_y + clc + adc temp_x + tax + + lda level2, X + ldx #5 + jsr mul_x + tax + + lda metatiles+2, X + sta $2007 + lda metatiles+3, X + sta $2007 + + pla + tax + inx + cpx #16 + bne :- + iny + cpy #15 + bne @row_start_nmt2 + + + ; clear attributes + ;lda #0 + ;ldx #64 ; 64 bytes + ;: + ; lda #%11100100 +; + ; sta $2007 + ; dex + ; bne :- + + lda #0 + sta $50 + + ldy #0 : + tya + pha + + ldx #0 + : + tya + pha + txa + pha + + tya + asl + asl + asl + asl + asl + sta temp_y + + txa + asl + + clc + adc temp_y + + tax + + lda level2, X + tay + lda #5 + jsr mul_y + tay + lda metatiles+4, Y + sta temp_x + + lda level2+1, X + tay + lda #5 + jsr mul_y + tay + lda metatiles+4, Y + asl + asl + adc temp_x + sta temp_x + + lda level2+16, X + tay + lda #5 + jsr mul_y + tay + lda metatiles+4, Y + asl + asl + asl + asl + adc temp_x + sta temp_x + + lda level2+17, X + tay + lda #5 + jsr mul_y + tay + lda metatiles+4, Y + asl + asl + asl + asl + asl + asl + adc temp_x + sta $2007 + + ldx $50 + inx + stx $50 + + sta $60, X + + pla + tax + pla + tay + inx + cpx #8 + bne :- + + pla + tay + iny + cpy #8 + bne :-- rts