NMI and MAIN
Posted: Tue Jul 18, 2006 11:18 pm
Would it be good to use a main loop as well as an NMI? What would be the purpose of having a main loop run apart from an NMI? Can i use them in conjuntion?
Yes, I think it's good to do that.nineTENdo wrote:Would it be good to use a main loop as well as an NMI? What would be the purpose of having a main loop run apart from an NMI? Can i use them in conjuntion?
Making everything after the init code into an NMI-listener is actually rawther common in games published by Nintendo. It's also the case in the Java platform (standalone programs or applets), where you build a frame, toss stuff into its panel, and then all the logic runs as event listeners inside the panel.Memblers wrote:here are some games though that run everything in the NMI, with the code after startup just being an infinite JMP loop. I think that's kinda weird though.
Yes, reentrancy has its benefits. One is music catch-up (as seen in Pokémon for Game Boy). Another is not missing serial communication events, especially on a Vs Dualsystem or a pair of Game Boy systems.I think Metroid even enabled NMIs inside it's NMI routine so they could happen recursively, for when it takes longer than a frame.
Code: Select all
;other code-----------------------------------------------
lda #$23
sta $2006
lda #$D0
sta $2006 ;Point to right spot in Attr. Map
ldx #$00
ldy #$20
.DrawAtt
lda .Attribute,X
sta $2007
inx
dey
bne .DrawAtt
.Attribute
dc.b #$40,#$55,#$01,#$01 ,#$00,#$00,#$00,#$00
dc.b #$04,#$05,#$51,#$00 ,#$00,#$00,#$00,#$00
dc.b #$04,#$11,#$44,#$00 ,#$00,#$00,#$00,#$00
dc.b #$04,#$01,#$00,#$00 ,#$01,#$00,#$00,#$00
; Other code ---------------------------------------------------------------
; than this------------------------------------------------------------------
InitPal
pha
txa
pha
tya
pha
lda #$3F
sta $2006
sty $2006
ldy #$08 ;Set up 8 colours.
.InitPal1
lda .Palette,X
sta $2007
inx
dey
bne .InitPal1
pla
tay
pla
tax
pla
rts
.Palette
dc.b #$0D,#$1D,#$2D,#$00 ,#$0D,#$10,#$3D,#$30 ;Greys
dc.b #$0D,#$07,#$16,#$27 ,#$0D,#$37,#$38,#$30 ;Red-Yellow
dc.b #$0D,#$01,#$11,#$1C ,#$0D,#$2C,#$3C,#$30 ;Blue-Cyan
dc.b #$0D,#$03,#$14,#$25 ,#$0D,#$36,#$37,#$30 ;Magenta-Yellow
dc.b #$0D,#$05,#$06,#$07 ,#$0D,#$17,#$18,#$28 ;Rusty
dc.b #$0D,#$11,#$2C,#$2B ,#$0D,#$2A,#$38,#$26 ;Spectrum1
dc.b #$0D,#$16,#$39,#$2A ,#$0D,#$2C,#$11,#$13
Thanks Again
ELErm... well...nineTENdo wrote:IN yy-CHR You can change the attributes in the pallete from 00-FF.
Right. If you want, you can think of there being 4 different 4-color palettes available for your background:So you can if you wanted to, use attributes to setup your screen. Which would allow you to color more of the screen directly (per 4x4 cell (32x32 pixel))and use more colors right.
Generally, you wouldn't. That guy in that other thread most likely had an error in his code.Oh yeah why would you want to start your pallete at $3F3F?