Code help to make the screen go blue. (Nesasm.)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
validusername
Posts: 2
Joined: Sat Aug 08, 2020 1:45 am

Code help to make the screen go blue. (Nesasm.)

Post by validusername » Sat Aug 08, 2020 2:49 am

Hi all!

I have this code:

Code: Select all

  .inesprg 1   ; 1x 16KB PRG code
  .ineschr 1   ; 1x  8KB CHR data
  .inesmap 0   ; mapper 0 = NROM, no bank swapping
  .inesmir 1   ; background mirroring
  

;;;;;;;;;;;;;;;

    
  .bank 0
  .org $C000 
RESET:
  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
   
vblankwait2:      ; Second wait for vblank, PPU is ready after this
  BIT $2002
  BPL vblankwait2


  LDA %10000000   ;intensify blues
  STA $2001

Forever:
  JMP Forever     ;jump back to Forever, infinite loop
  
 

NMI:
  RTI
 
;;;;;;;;;;;;;;  
  
  
  
  .bank 1
  .org $FFFA     ;first of the three vectors starts here
  .dw NMI        ;when an NMI happens (once per frame if enabled) the 
                   ;processor will jump to the label NMI:
  .dw RESET      ;when the processor first turns on or is reset, it will jump
                   ;to the label RESET:
  .dw 0          ;external interrupt IRQ is not used in this tutorial
  
  
;;;;;;;;;;;;;;  
  
  
  .bank 2
  .org $0000
  .incbin "mario.chr"   ;includes 8KB graphics file from SMB1


i have the mario.chr file in the same dir as the source code file. I assemble the assembly code with nesasm background.asm command. Isn't it supposed to display a blue screen? I am getting a green one.

I am trying to follow this tutorial: https://nerdy-nights.nes.science/#main_tutorial-3

Thanks in advance for the help!!!

User avatar
tokumaru
Posts: 11859
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Code help to make the screen go blue. (Nesasm.)

Post by tokumaru » Sat Aug 08, 2020 5:44 am

Well, you are turning the blue emphasis bit on, but you never selected a background color to begin with, so there's no way to tell for sure which color is being emphasized (green with blue emphasis still looks green). This code probably relies on the palette being set to 0s (all grays) on start up, which's not guaranteed at all on real hardware. Different emulators will also initialize the palette differently on start up.

What you want to do is set the background color to a known value, so that the blue emphasis has the effect you're expecting. You need something like this before your "intensify blues" code:

Code: Select all

;point the PPU to the address of the background color
lda #$3f
sta $2006
lda #$00
sta $2006

;write a known color there
lda #$30 ;white
sta $2007

;point the PPU away from the palette
lda #$00
sta $2006
sta $2006

Pokun
Posts: 1512
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Code help to make the screen go blue. (Nesasm.)

Post by Pokun » Sat Aug 08, 2020 5:53 am

Yeah that's another shortcoming of the Nerdy Nights tutorial. It relies on inaccurate emulator behaviour by not clearing the screen or setting the backdrop colour, so there will be garbage on the screen and colour will be random.

User avatar
tokumaru
Posts: 11859
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Code help to make the screen go blue. (Nesasm.)

Post by tokumaru » Sat Aug 08, 2020 6:59 am

In this basic example I think that rendering is still off, so garbage in VRAM shouldn't be a problem. It will be once rendering is turned on, though.

Pokun
Posts: 1512
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Code help to make the screen go blue. (Nesasm.)

Post by Pokun » Sat Aug 08, 2020 5:28 pm

Oh, right.

validusername
Posts: 2
Joined: Sat Aug 08, 2020 1:45 am

Re: Code help to make the screen go blue. (Nesasm.)

Post by validusername » Tue Aug 25, 2020 10:35 am

Thank you all for the help will try. (I am not that active on this forum so sorry for the long delays.)

edit: * i dunno what i was thinking when i wrote that. It should just be Thank you all for the help (...

Post Reply