A Simple NES Game

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: A Simple NES Game

Post by Falco Girgis »

Hell yeah! I'd hit it! :mrgreen:
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
Posts: 307
Joined: Sun Mar 13, 2011 7:57 pm
Current Project: 2D RPG & NES Platformer
Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
Programming Language of Choice: C/++
Location: Canada

Re: A Simple NES Game

Post by Light-Dark »

EDIT: Here's a video of it in action



Adding on to the sine-wave like movement pattern discussion in this thread:

There is in fact a way to create a more precise replica of a sinusoidal curve on the NES through the use of a lookup table in ROM. This is how I've gone about generating a smooth curve for ai movemnt in my new platformer engine:
void Generate_Table(){
    int i;
    float angle = 0.0;
    for(i = 0;i <256;i++){
        table = ((sin(angle)*127.0)+128.0);
        printf("8bit value:%i\n",table);
        angle += 0.125;
    }
}


Here is how I use it in my NES engine:
;SOMEWHERE IN ROM
sine:
   .incbin "sinetable.bin" ; 256 byte binary file consisting of the generated sine table

And here is how the table is used

Code: Select all

Sine_Wave:
	ldy #$05					;Set xVel to 3
	lda #$03
	sta (AI_PTR),y
	ldy #$08
	lda (AI_PTR),y				; action frame
	tax						
	lda sine,x					; do sine table lookup
	lsr							; divide  by 2 to compress the arc size
    sta Test					; temporary test variable
	clc							
	adc #$40					; add a decent y offset
	ldy #$00					
	sta (AI_PTR),y				; save it to the Y-position of AI

	ldy #$08					; reload action frame 
	lda (AI_PTR),y				; ^ I know this seems inefficient lol
	tax						
	inx							; increment it
	txa
	sta (AI_PTR),y				; save it back
	jmp AI_ActionDone			; exit from the jumptable routine
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step
Image
Post Reply