Edit:
I now realize I'm an idiot and wrote "DB." instead of ".DB".
I have a simple SNES program that is supposed to color the top part of the screen a light blue color, and the bottom of the screen a dark blue color. Whenever I try to run it in an emulator, the image results in an interlaced picture with two different incorrect colors appearing on different scanlines. The code for the program is as follows.
Note that I am using mode 5 with interlacing, but I do not think that is related to the problem, because even when using other modes, the problem persists. I included the file in the post. I tested it in Snes9x and zsnes.
I now realize I'm an idiot and wrote "DB." instead of ".DB".
I have a simple SNES program that is supposed to color the top part of the screen a light blue color, and the bottom of the screen a dark blue color. Whenever I try to run it in an emulator, the image results in an interlaced picture with two different incorrect colors appearing on different scanlines. The code for the program is as follows.
Code:
.include "Header.inc"
.include "Snes_Init.asm"
; Needed to satisfy interrupt definition in "Header.inc".
VBlank:
;Set up HDMA
stz $420C ; Reset HDMA
lda #%00000010 ; A to B, Absolute, (3 bits unused), 2 bytes to 1 register
sta $4300
lda #$22 ; Modify address $(21)22 (Background Color)
sta $4301
lda #$00 ; Set HDMA table bank to 7E
sta $4302
rep #$20
lda HDMA_Table ; Set HDMA table to HDMA table pointer
sta $4303
lda #%00000001 ; Activate the first HDMA channel
sta $420C
rti
.BANK 0
.SECTION "Main"
Start:
; Initialize the SNES.
Snes_Init
; Initialize input
Input_Init
; Set the background color to blue.
sep #$20 ; Set the A register to 8-bit.
lda #%10000000 ; Force VBlank by turning off the screen.
sta $2100
lda #%01110101 ; 1-BG4 tilesize = 8x8 (not used), 2-BG3 tilesize = 16x16, 3-BG2 tilesize = 16x16, 4-BG1 tilesize = 16x16, Background priority set to 0 (?), 6-8- Set graphics to Mode 5
sta $2105
lda #%11000111 ; Load the low byte of the blue color.
sta $2122
lda #%01100001 ; Load the high byte of the blue color.
sta $2122
; Set up HDMA table
HDMA_Table:
DB. #$7F ; Wait for 127 scanlines after transferring
DB. #%11000111 ; Low byte of light blue color
DB. #%01100001 ; High byte of light blue color
DB. #$34 ; Wait for 52 scanlines after transferring
DB. #%11000111 ; Low byte of light blue color
DB. #%01100001 ; High byte of light blue color
DB. #$01 ; Do not wait for a scanline, because this is the final transfer
DB. #%01100100 ; Low byte of dark blue color
DB. #%01011101 ; High byte of dark blue color
DB. #$00 ; Null byte to end table
lda #$80
sta $4200 ;Enable VBlank NMI
rep #$20 ; set the accumulator (A) register into 16 bit mode
sep #$10 ; set the index (X and Y) register into 8 bit mode
ldy #$80 ; we will try to write 128 ($80) bytes in one row ...
sty $2115 ; ... and we will let the PPU let this know.
stz $2116 ; Set the VRAM address to zero
lda #%00001111 ; End VBlank, setting brightness to 15 (100%).
sta $2100
; Loop forever.
MainLoop:
jmp MainLoop
.ENDS
.include "Snes_Init.asm"
; Needed to satisfy interrupt definition in "Header.inc".
VBlank:
;Set up HDMA
stz $420C ; Reset HDMA
lda #%00000010 ; A to B, Absolute, (3 bits unused), 2 bytes to 1 register
sta $4300
lda #$22 ; Modify address $(21)22 (Background Color)
sta $4301
lda #$00 ; Set HDMA table bank to 7E
sta $4302
rep #$20
lda HDMA_Table ; Set HDMA table to HDMA table pointer
sta $4303
lda #%00000001 ; Activate the first HDMA channel
sta $420C
rti
.BANK 0
.SECTION "Main"
Start:
; Initialize the SNES.
Snes_Init
; Initialize input
Input_Init
; Set the background color to blue.
sep #$20 ; Set the A register to 8-bit.
lda #%10000000 ; Force VBlank by turning off the screen.
sta $2100
lda #%01110101 ; 1-BG4 tilesize = 8x8 (not used), 2-BG3 tilesize = 16x16, 3-BG2 tilesize = 16x16, 4-BG1 tilesize = 16x16, Background priority set to 0 (?), 6-8- Set graphics to Mode 5
sta $2105
lda #%11000111 ; Load the low byte of the blue color.
sta $2122
lda #%01100001 ; Load the high byte of the blue color.
sta $2122
; Set up HDMA table
HDMA_Table:
DB. #$7F ; Wait for 127 scanlines after transferring
DB. #%11000111 ; Low byte of light blue color
DB. #%01100001 ; High byte of light blue color
DB. #$34 ; Wait for 52 scanlines after transferring
DB. #%11000111 ; Low byte of light blue color
DB. #%01100001 ; High byte of light blue color
DB. #$01 ; Do not wait for a scanline, because this is the final transfer
DB. #%01100100 ; Low byte of dark blue color
DB. #%01011101 ; High byte of dark blue color
DB. #$00 ; Null byte to end table
lda #$80
sta $4200 ;Enable VBlank NMI
rep #$20 ; set the accumulator (A) register into 16 bit mode
sep #$10 ; set the index (X and Y) register into 8 bit mode
ldy #$80 ; we will try to write 128 ($80) bytes in one row ...
sty $2115 ; ... and we will let the PPU let this know.
stz $2116 ; Set the VRAM address to zero
lda #%00001111 ; End VBlank, setting brightness to 15 (100%).
sta $2100
; Loop forever.
MainLoop:
jmp MainLoop
.ENDS
Note that I am using mode 5 with interlacing, but I do not think that is related to the problem, because even when using other modes, the problem persists. I included the file in the post. I tested it in Snes9x and zsnes.