Hey guys. After reading around for a while I've decided to start doing some assembling. I'm trying to write a simple program (based on Nerdy Nights) that sets the red emphasis bit when you press the A button. The problem is that, well, nothing happens. I've tried to correct it myself, but I can't seem to find out what is wrong. I'm sure it's something painfully obvious. I have emphasis set as a variable because I eventually want to scroll through the emphasis bits when you press the A button by using ASL. Thanks to tokumaru for his template
Code:
;----------------------------------------------------------------
; constants
;----------------------------------------------------------------
PRG_COUNT = 2 ;1 = 16KB, 2 = 32KB
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
FRAMECOUNTER = 0
EMPHASIS = %00100000
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db PRG_COUNT ;number of 16KB PRG-ROM pages
.db $01 ;number of 8KB CHR-ROM pages
.db $00|MIRRORING ;mapper 0 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; Init
;----------------------------------------------------------------
.base $8000
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
STA $0300, x
INX
BNE clrmem
vblankwait2: ; Second wait for vblank, PPU is ready after this
BIT $2002
BPL vblankwait2
;----------------------------------------------------------------
; code
;----------------------------------------------------------------
LDA #%10000000 ; enable NMI
STA $2000
Loop:
lda FRAMECOUNTER ;wait for vblank
cmp FRAMECOUNTER
beq Loop
ReadController1:
lda #$01
sta $4016
lda #$00
sta $4016 ; tell both the controllers to latch buttons
lda $4016 ; player 1 - A button
and #%00000001
beq Loop ;if A is not pressed, wait for vblank
lda EMPHASIS ;if A is pressed
sta $2001
JMP Loop ;jump back to Loop, infinite loop
NMI:
INC FRAMECOUNTER
RTI
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.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
;;;;;;;;;;;;;;
.incbin mario.chr ;includes 8KB graphics file from SMB1
; constants
;----------------------------------------------------------------
PRG_COUNT = 2 ;1 = 16KB, 2 = 32KB
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
FRAMECOUNTER = 0
EMPHASIS = %00100000
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db PRG_COUNT ;number of 16KB PRG-ROM pages
.db $01 ;number of 8KB CHR-ROM pages
.db $00|MIRRORING ;mapper 0 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; Init
;----------------------------------------------------------------
.base $8000
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
STA $0300, x
INX
BNE clrmem
vblankwait2: ; Second wait for vblank, PPU is ready after this
BIT $2002
BPL vblankwait2
;----------------------------------------------------------------
; code
;----------------------------------------------------------------
LDA #%10000000 ; enable NMI
STA $2000
Loop:
lda FRAMECOUNTER ;wait for vblank
cmp FRAMECOUNTER
beq Loop
ReadController1:
lda #$01
sta $4016
lda #$00
sta $4016 ; tell both the controllers to latch buttons
lda $4016 ; player 1 - A button
and #%00000001
beq Loop ;if A is not pressed, wait for vblank
lda EMPHASIS ;if A is pressed
sta $2001
JMP Loop ;jump back to Loop, infinite loop
NMI:
INC FRAMECOUNTER
RTI
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.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
;;;;;;;;;;;;;;
.incbin mario.chr ;includes 8KB graphics file from SMB1