|
hello,
I have been putting together my first game project, and have run into a slight graphical glitch. From what I read, all writes to VRAM should be executed during vblank, and in most emulators the code I have works.. I tried the game in nestopia. When I perform a hard reset (power on/off, or on load), occasionally one or two garbage tiles appear on-screen. Also, in PAL mode (or any mode where the top 8 scanlines are visible), the second entry in pattern table appears 100% of the time in the top left corner (bg is supposed to be disabled). The first entry in PT is a blank, and there are three entries total. My startup code looks something like this (compiler is nesasm):
main:
cld ; clear decimal flag sei ; disable interrupts ldx #$FF ; ensure stack is pointing to top txs inx
jsr waitvb stx $2000 stx $2001 ; this SHOULD disable the PPU during startup ; clear $0000-$07FF in RAM. ldy #$07 sty <$01 lda #$00 sta <$00
clr_ram: sta [$00],y ; clear $100 bytes dey bne clr_ram
dec <$01 bpl clr_ram
;Initialize the Palette lda #$3f sta $2006 lda #$00 sta $2006 tay do_pal: lda palette,y sta $2007 iny cpy #$20 bne do_pal
;clear out $0000-$1FFF in VRAM lda #0 sta $2006 sta $2006 ldy #$20 cleartiles1: ldx #0 cleartiles2: sta $2007 inx bne cleartiles2 dey bne cleartiles1
tiles: ; setup the pattern table lda #0 sta $2006 sta $2006
ldy #0 tiles1: lda tileset, y sta $2007 iny cpy #$30 bne tiles1
inits: ldy #0 inits1: lda initdata, y sta P1.PX, y lda initsprites, y sta P1A.Y, y iny cpy #$10 bne inits1
lda #7 sta $4014
jsr waitvb ;!Initialize the PPU! lda #%10000000 ;NMI on Vblank on! sta $2000 lda #%00010100 ;sprites on, no clipping sta $2001 cli
-----
Other than the glitch on startup, the game otherwise functions normally.
|