.org $8000
.org $8000When the assembler runs, it will do a find/replace to set MyFunction to $8000. The if you have any code that uses MyFunction like:
MyFunction:
STA MyFunctionIt will find/replace to:
STA $8000
.org $8000
MyFunction:
JMP MyFunction
.org $8000
MyFunction:
LDA #$FF
JMP MyFunction
.org $8000This code would just continually run the loop, loading the hex value $FF into the accumulator each time.
MyFunction: ; loads FF into accumulator
LDA #$FF
JMP MyFunction
$0000-0800 - Internal RAM, 2KB chip in the NESAny of the game cart sections can be bank switched to get access to more memory, but memory mappers will not be included in this tutorial.
$2000-2007 - PPU access ports
$4000-4017 - Audio and controller access ports
$6000-7FFF - Optional WRAM inside the game cart
$8000-FFFF - Game cart ROM
LDA #$FF ;load the hex value $FF (decimal 256) into A
STA $0000 ;store the accumulator into memory location $0000, internal RAM
LDX $0000 ;load the value at memory location $0000 into X
INX ;increment X X = X + 1
STY $00BA ;store Y into memory location $00BA
TYA ;transfer Y into Accumulator
LDA #$0A ; LoaD the value 0A into the accumulator A
; the number part of the opcode can be a value or an address
; if the value is zero, the zero flag will be set.
LDX $0000 ; LoaD the value at address $0000 into the index register X
; if the value is zero, the zero flag will be set.
LDY #$FF ; LoaD the value $FF into the index register Y
; if the value is zero, the zero flag will be set.
STA $2000 ; STore the value from accumulator A into the address $2000
; the number part must be an address
STX $4016 ; STore value in X into $4016
; the number part must be an address
STY $0101 ; STore Y into $0101
; the number part must be an address
TAX ; Transfer the value from A into X
; if the value is zero, the zero flag will be set
TAY ; Transfer A into Y
; if the value is zero, the zero flag will be set
TXA ; Transfer X into A
; if the value is zero, the zero flag will be set
TYA ; Transfer Y into A
; if the value is zero, the zero flag will be set
ADC #$01 ; ADd with Carry
; A = A + $01 + carry
; if the result is zero, the zero flag will be set
SBC #$80 ; SuBtract with Carry
; A = A - $80 - (1 - carry)
; if the result is zero, the zero flag will be set
CLC ; CLear Carry flag in status register
; usually this should be done before ADC
SEC ; SEt Carry flag in status register
; usually this should be done before SBC
INC $0100 ; INCrement value at address $0100
; if the result is zero, the zero flag will be set
DEC $0001 ; DECrement $0001
; if the result is zero, the zero flag will be set
INY ; INcrement Y register
; if the result is zero, the zero flag will be set
INX ; INcrement X register
; if the result is zero, the zero flag will be set
DEY ; DEcrement Y
; if the result is zero, the zero flag will be set
DEX ; DEcrement X
; if the result is zero, the zero flag will be set
ASL A ; Arithmetic Shift Left
; shift all bits one position to the left
; this is a multiply by 2
; if the result is zero, the zero flag will be set
LSR $6000 ; Logical Shift Right
; shift all bits one position to the right
; this is a divide by 2
; if the result is zero, the zero flag will be set
CMP #$01 ; CoMPare A to the value $01
; this actually does a subtract, but does not keep the result
; instead you check the status register to check for equal,
; less than, or greater than
CPX $0050 ; ComPare X to the value at address $0050
CPY #$FF ; ComPare Y to the value $FF
JMP $8000 ; JuMP to $8000, continue running code there
BEQ $FF00 ; Branch if EQual, contnue running code there
; first you would do a CMP, which clears or sets the zero flag
; then the BEQ will check the zero flag
; if zero is set (values were equal) the code jumps to $FF00 and runs there
; if zero is clear (values not equal) there is no jump, runs next instruction
BNE $FF00 ; Branch if Not Equal - opposite above, jump is made when zero flag is clear
.inesprg 1 ; 1x 16KB bank of PRG code
.ineschr 1 ; 1x 8KB bank of CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 1 ; background mirroring (ignore for now)
.bank 0
.org $C000
;some code here
.bank 1
.org $E000
; more code here
.bank 2
.org $0000
; graphics here
.bank 2
.org $0000
.incbin "mario.chr" ;includes 8KB graphics file from SMB1
.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 0
.org $C000
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
PPUMASK ($2001)
76543210
||||||||
|||||||+- Grayscale (0: normal color; 1: AND all palette entries
||||||| with 0x30, effectively producing a monochrome display;
||||||| note that colour emphasis STILL works when this is on!)
||||||+-- Disable background clipping in leftmost 8 pixels of screen
|||||+--- Disable sprite clipping in leftmost 8 pixels of screen
||||+---- Enable background rendering
|||+----- Enable sprite rendering
||+------ Intensify reds (and darken other colors)
|+------- Intensify greens (and darken other colors)
+-------- Intensify blues (and darken other colors)
LDA %10000000 ;intensify blues
STA $2001
Forever:
JMP Forever ;infinite loop
Hi Bunnyboy,
I dont know if its my browser, but I notice a lot of the code snippets above are showing up altogether on the same line. So if I was to copy and paste those into a file, it obviously wouldnt compile.
The only other comment I would make would be mentioning something about CONSTANTS or DEFINES
I can see that you have some declared for PPUMASK, etc.. in the code but there is no separate heading for them like you have for COMMENTS and OPERANDS. That threw me for a loop since the syntax is slightly different for those constants between different assemblers.
Keep up the good work
Al
My Gameboy collection 97% complete. My N64 collection 88% complete
My Gamecube collection 99% complete My NES collection 97% complete
LOOKING FOR GARAGE CART,pm me with buy or trading offer
Changing it does not help
Still think that DOS is the problem
I can open and see the mario.chr and the background.asm. Only the background.bat wont open,black screen with not recognized bla bla
LOOKING FOR GARAGE CART,pm me with buy or trading offer
thats not the problem.
have downloaded the background zip, the nesasm3 en de fceuxd sp
i have unzipped the background and have put it in the nesasm3 but when i try to dubbel click the bat file the nesasm3 programm is not recignized as a internal or ext. programm or command?
LOOKING FOR GARAGE CART,pm me with buy or trading offer
LOOKING FOR GARAGE CART,pm me with buy or trading offer