Re: A Simple NES Game
Posted: Tue Apr 23, 2013 10:42 am
Hell yeah! I'd hit it!
The Next Generation of 2D Roleplaying Games
http://elysianshadows.com/phpBB3/
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; } }
;SOMEWHERE IN ROM sine: .incbin "sinetable.bin" ; 256 byte binary file consisting of the generated sine table
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