Hi,

I have just registered to this bbs, but I've been tracing topics here for a very long time. I decided to register, because of a little problem with writing data to PPU. I need to write them during VBlank and all would seem ok, if there isn't stupid behaviour of PPU or rather my "unknowledge".

I want to put chars on the screen (background), but I cannot switch off the screen and put all together. They need to be shown one by one. And I don't know why they're putting there from the right side?! For me it's impossible. Can someone repair this code? I'd like to see, how it should be coded to not to do the same mistake next time.

Thank you

I have just registered to this bbs, but I've been tracing topics here for a very long time. I decided to register, because of a little problem with writing data to PPU. I need to write them during VBlank and all would seem ok, if there isn't stupid behaviour of PPU or rather my "unknowledge".

**Code:**

;-- CODE START --;

.inesmir 0 ;- don't care about mirroring

.inesmap 0 ;- Mapper 2!!!

.inesprg 1 ;- This might be 2 (I think NESASM.EXE goes by 8kb PRGs, so therefore the 4)

.ineschr 1

.bank 1 ; should be the last bank

.org $FFFA

.dw NMI

.dw $8000

.dw 0

.bank 0 ; first bank loaded at $8000

.org $8000

SEI ; disable IRQs

CLD ; disable decimal mode

LDX #$40

STX $4017 ; disable APU frame IRQ

LDX #$FF

TXS ; Set up stack

INX ; now X = 0

STX $2000 ; disable NMI

STX $2001 ; disable rendering

STX $4010 ; disable DMC IRQs

vblankwait1: ; First wait for vblank to make sure PPU is ready

BIT $2002

BPL vblankwait1

clrmem:

LDA #$00

STA $0000, x

STA $0100, x

STA $0200, x

STA $0400, x

STA $0500, x

STA $0600, x

STA $0700, x

LDA #$FE

STA $0300, x

INX

BNE clrmem

ldx #00

vblankwait2: ; Second wait for vblank, PPU is ready after this

BIT $2002

BPL vblankwait2

lda #%10001000

sta $2000

lda #%00011000

sta $2001

lda #$3F

sta $11

lda #$00

sta $12

lda #$41

sta $13

lda #1

sta $14

czekajtu:

lda $14

cmp #00

bne czekajtu

jsr lwait

jsr lwait

jsr lwait

jsr lwait

jsr lwait

jsr lwait

jsr lwait

;pauza: jmp pauza

lda #$3F

sta $11

lda #0

sta $12

lda #$0D

sta $13

lda #1

sta $14

czekajtu2:

lda $14

cmp #00

bne czekajtu2

LDX #$00

STX $0003

LoadBackground:

lda #$20

sta $11

ldx $03

stx $12

lda #$1

sta $13

lda #1

sta $14

czekajtu3:

lda $14

cmp #00

bne czekajtu3

ldx $03

inx

stx $03

cpx #$FF

bne LoadBackground

label:

jmp label

NMI:

pha

txa

pha

tya

pha

lda $2002

lda #0

sta $2000

lda #%10000000

sta $2000

lda $14

cmp #00

beq brakgfx

lda $11

sta $2006

lda $12

sta $2006

lda $13

sta $2007

lda #0

sta $14

brakgfx:

pla

tay

pla

tax

pla

rti

longwait:

ldy #$FF

lwait:

jsr pleasewait

dey

cpy #00

bne lwait

rts

pleasewait:

ldx #$FF

wait:

dex

cpx #00

bne wait

rts

.bank 2

.org $0000

.incbin "our.spr"

;-- CODE END --;

.inesmir 0 ;- don't care about mirroring

.inesmap 0 ;- Mapper 2!!!

.inesprg 1 ;- This might be 2 (I think NESASM.EXE goes by 8kb PRGs, so therefore the 4)

.ineschr 1

.bank 1 ; should be the last bank

.org $FFFA

.dw NMI

.dw $8000

.dw 0

.bank 0 ; first bank loaded at $8000

.org $8000

SEI ; disable IRQs

CLD ; disable decimal mode

LDX #$40

STX $4017 ; disable APU frame IRQ

LDX #$FF

TXS ; Set up stack

INX ; now X = 0

STX $2000 ; disable NMI

STX $2001 ; disable rendering

STX $4010 ; disable DMC IRQs

vblankwait1: ; First wait for vblank to make sure PPU is ready

BIT $2002

BPL vblankwait1

clrmem:

LDA #$00

STA $0000, x

STA $0100, x

STA $0200, x

STA $0400, x

STA $0500, x

STA $0600, x

STA $0700, x

LDA #$FE

STA $0300, x

INX

BNE clrmem

ldx #00

vblankwait2: ; Second wait for vblank, PPU is ready after this

BIT $2002

BPL vblankwait2

lda #%10001000

sta $2000

lda #%00011000

sta $2001

lda #$3F

sta $11

lda #$00

sta $12

lda #$41

sta $13

lda #1

sta $14

czekajtu:

lda $14

cmp #00

bne czekajtu

jsr lwait

jsr lwait

jsr lwait

jsr lwait

jsr lwait

jsr lwait

jsr lwait

;pauza: jmp pauza

lda #$3F

sta $11

lda #0

sta $12

lda #$0D

sta $13

lda #1

sta $14

czekajtu2:

lda $14

cmp #00

bne czekajtu2

LDX #$00

STX $0003

LoadBackground:

lda #$20

sta $11

ldx $03

stx $12

lda #$1

sta $13

lda #1

sta $14

czekajtu3:

lda $14

cmp #00

bne czekajtu3

ldx $03

inx

stx $03

cpx #$FF

bne LoadBackground

label:

jmp label

NMI:

pha

txa

pha

tya

pha

lda $2002

lda #0

sta $2000

lda #%10000000

sta $2000

lda $14

cmp #00

beq brakgfx

lda $11

sta $2006

lda $12

sta $2006

lda $13

sta $2007

lda #0

sta $14

brakgfx:

pla

tay

pla

tax

pla

rti

longwait:

ldy #$FF

lwait:

jsr pleasewait

dey

cpy #00

bne lwait

rts

pleasewait:

ldx #$FF

wait:

dex

cpx #00

bne wait

rts

.bank 2

.org $0000

.incbin "our.spr"

;-- CODE END --;

I want to put chars on the screen (background), but I cannot switch off the screen and put all together. They need to be shown one by one. And I don't know why they're putting there from the right side?! For me it's impossible. Can someone repair this code? I'd like to see, how it should be coded to not to do the same mistake next time.

Thank you