lda #$3F ;set ppu to start of palette sta $2006 lda #$00 sta $2006 ldx #$00
.inesprg 1 .inesmap 0 .inesmir 0 .ineschr 0 .bank 1 .org $FFFA .dw 0 .dw Start .dw 0 .bank 0 .org $0000YPos .db 00XPos .db 00 .org $8000Start: jsr screen_off;ekran wylaczony jsr cleartiles;czyscimy 4KB VRAMu jsr tiles;kopiujemy tilesy z defchr do VRAM (w karcie) jsr loadNames jsr screen_on;wlaczamy ekran jsr sound lda #$3F;set ppu to start of palette sta $2006 lda #$00 sta $2006 ldx #$00loadpal: lda Paldata,x sta $2007 inx cpx #$20 bne loadpalinfinite: jsr vwait ldx #$00;set start SPRRAM stx $2003 ldx #$00 stx $2003 lda YPos;Y sta $2004 lda #$01;tile number w pamieci VRAM na karcie sta $2004 lda #%00000000;attr sta $2004 lda XPos;X sta $2004 lda #$01;reset pada (od) sta $4016 lda #$00 sta $4016 lda $4016 lda $4016 lda $4016 lda $4016;reset pada (do) lda $4016 and #1 bne PressU lda $4016 and #1 bne PressD lda $4016 and #1 bne PressL lda $4016 and #1 bne PressR jmp PressNPressU: ;tutaj jest to, co ma byc odpalone gdy wciskamy up lda YPos sbc #1 sta YPos jmp PressNPressD: ;tutaj jest to, co ma byc odpalone gdy wciskamy down lda YPos adc #1 sta YPos jmp PressNPressL: ;tutaj jest to, co ma byc odpalone gdy wciskamy left lda XPos sbc #1 sta XPos jmp PressNPressR: ;tutaj jest to, co ma byc odpalone gdy wciskamy prawo ; jak dodam jsr vwait, to chodzi wolniej lda XPos; bo czeka za kazdym ruchem na vb adc #1 sta XPos jmp PressNPressN: ;tutaj jest to, co ma byc wykonane gdy nic nie wciskamy jmp infinitescreen_on: jsr vwait lda #%00000000 sta $2000 lda #%00011110;spr on, bg off, spr no clipp sta $2001 rtsscreen_off: jsr vwait lda #0 sta $2000 sta $2001 rtsvwait: bit $2002 bpl vwait rtsPaldata: .db $3F,$20,$10,$00,$3F,$10,$10,$10,$3F,$10,$10,$10,$3F,$00,$00,$00 .db $3F,$16,$19,$01,$3F,$00,$00,$00,$3F,$00,$00,$00,$3F,$00,$00,$00loadNames: jsr vwait lda #$20;set ppu to start vram sta $2006 lda #$20 sta $2006loadNames1: lda nametable,x sta $2007 inx cpx #32;zmieniamy w zaleznosci od wielkosci nametable bne loadNames1 rtsnametable: .db $01,$01,$01,$01,$02,$02,$02,$02,$01,$01,$01,$01,$02,$02,$02,$02 .db $01,$01,$01,$01,$02,$02,$02,$02,$01,$01,$01,$01,$02,$02,$02,$02tiles: ;copy defchr tiles to VRAM lda #0 ;set VRAM row for first row of tiles ($0000) sta $2006 lda #$10 ;skip the first tile (blank space) sta $2006 ldy #0 ;reset indexertiles1: lda tileset,y sta $2007 iny cpy #$20 ;number of tiles x 16 bytes ($10) per tile bne tiles1 rtscleartiles: ;clears out $0000-$0FFF in VRAM jsr vwait lda #0 sta $2006 sta $2006 ldy #$10cleartiles1: ldx #0cleartiles2: sta $2007 dex bne cleartiles2 dey bne cleartiles1 rtssound: lda %00011111 sta $4015 lda #%10101011 sta $4000 lda #%11111111 sta $4001 lda #%11111111 sta $4002 lda #%11111111 sta $4003 rtstileset: .defchr $23333331,\ $32000013,\ $30200103,\ $30021003,\ $30012003,\ $30100203,\ $31000023,\ $13333332 .defchr $30000003,\ $00000000,\ $00223300,\ $00211300,\ $00211300,\ $00223300,\ $00000000,\ $30000003 .defchr $00001111,\ $00110000,\ $11000000,\ $00000000,\ $00000000,\ $00000000,\ $00000000,\ $00000000; .defchr $00000000,\; $00000000,\; $00000000,\; $00000000,\; $00000000,\; $00000000,\; $00000000,\; $00000000;dummy tile
+---------+----------------------------------------------------------+ | $4000 | pAPU Pulse #1 Control Register (W) | | $4001 | pAPU Pulse #1 Ramp Control Register (W) | | $4002 | pAPU Pulse #1 Fine Tune (FT) Register (W) | | $4003 | pAPU Pulse #1 Coarse Tune (CT) Register (W) | | $4004 | pAPU Pulse #2 Control Register (W) | | $4005 | pAPU Pulse #2 Ramp Control Register (W) | | $4006 | pAPU Pulse #2 Fine Tune Register (W) | | $4007 | pAPU Pulse #2 Coarse Tune Register (W) | | $4008 | pAPU Triangle Control Register #1 (W) | | $4009 | pAPU Triangle Control Register #2 (?) | | $400A | pAPU Triangle Frequency Register #1 (W) | | $400B | pAPU Triangle Frequency Register #2 (W) | | $400C | pAPU Noise Control Register #1 (W) | | $400D | Unused (???) | | $400E | pAPU Noise Frequency Register #1 (W) | | $400F | pAPU Noise Frequency Register #2 (W) | | $4010 | pAPU Delta Modulation Control Register (W) | | $4011 | pAPU Delta Modulation D/A Register (W) | | $4012 | pAPU Delta Modulation Address Register (W) | | $4013 | pAPU Delta Modulation Data Length Register (W) | +---------+----------------------------------------------------------+ | $4014 | Sprite DMA Register (W) | | | | | | Transfers 256 bytes of memory into SPR-RAM. The address | | | read from is $100*N, where N is the value written. | +---------+----------------------------------------------------------+ | $4015 | pAPU Sound/Vertical Clock Signal Register (R) | | | | | | D6: Vertical Clock Signal IRQ Availability | | | 0 = One (1) frame occuring, hence IRQ cannot | | | occur | | | 1 = One (1) frame is being interrupted via IRQ | | | D4: Delta Modulation | | | D3: Noise | | | D2: Triangle | | | D1: Pulse #2 | | | D0: Pulse #1 | | | 0 = Not in use | | | 1 = In use | | +----------------------------------------------------------+ | | pAPU Channel Control (W) | | | | | | D4: Delta Modulation | | | D3: Noise | | | D2: Triangle | | | D1: Pulse #2 | | | D0: Pulse #1 | | | 0 = Channel disabled | | | 1 = Channel enabled | +---------+----------------------------------------------------------+
loadNames: lda #$20;set ppu to start vram sta $2006 lda #$00 sta $2006loadNames1: lda nametable1,x sta $2007 inx cpx #$FF bne loadNames1loadNames2: lda nametable2,x sta $2007 inx cpx #$FF bne loadNames2loadNames3: lda nametable3,x sta $2007 inx cpx #$FF bne loadNames3loadNames4: lda nametable4,x sta $2007 inx cpx #$FF bne loadNames4 rts
.inesprg 1 .ineschr 0 .inesmir 0 .inesmap 0 .org $C48D ; wczytujemy LOAD adres z NSF (z headerem to -$80) .incbin "demo.nsf"; include NSF (header -$80 lub bez) .org $8000RST: cld ; clear decimal flag sei ; disable interrupts lda #%00000000 ; nmi off sta $2000WaitV1: lda $2002 ; czekamy na vb aby ppu ruszylo dupsko bpl WaitV1WaitV2: lda $2002 ; i raz jeszcze dla pewnosci, ze ruszylo;) bpl WaitV2 lda #$00 ; zerujemy przed lopem ldx #$00 ; czyszczenia rejestrow dzwiekuClear_Sound: sta $4000,x ; prosty clear jak ch****... czysci 16bajtow 4000 inx cpx #$0F bne Clear_Sound lda #$10 sta $4010 lda #$00 ; czyscimi DPCM sta $4011 sta $4012 sta $4013 lda #%00001111 ; all channels on sta $4015 ; poza dpcm lda #$C0 ; synchronize the sound playback routine sta $4017 ; to the internal timing of the NES lda #$02 ; numer utworku w nsf ldx #$00 ; $00 dla NTSC i $01 dla PAL jsr $BE34 ; wczytujemy INIT adres z nsf lda #%10000000 ; enable vblank (NMI) sta $2000Loop: ; w kolo macieju... jmp LoopNMI: lda $2002 ; read $2002 to reset vb flag lda #%00000000 ; nmi off sta $2000 lda #%10000000 ; a teraz nmi on sta $2000 jsr $F2D0 ; wczytujemy PLAY adres z NSF rtiIRQ: rti .bank 1 .org $FFFA .dw NMI .dw RST .dw IRQ