Jump to content
  • entries
    334
  • comments
    900
  • views
    258,344

vertical motion


EricBall

424 views

The starfield now move up and down, following the sine wave, though in 8 line jumps. Smooth scrolling is next, but that requires some display list & display list list magic.

 

I've also started using a 6502 simulator for general debugging. Since a lot of 7800 code is data movement, it's reasonable to use a general 6502 simulator. I caught a couple of bugs this way. The biggest problem is the built-in assembler isn't DASM compatible and isn't as capable.

 

I've also made some major improvements to the SINE routine:

SINE	LDX	#3	; y[n+1] = y[n] - y[n-1] - y[n]/64K + y[n]
SEC
3$	LDA	STARY,X
SBC	STARYP,X
STA	STARYP,X
DEX
BPL	3$
LDA	STARY+2	; rounding
EOR	STARY	; reverse if negative
EOR	#$80	; reverse for subtract
ASL		; put in Carry
LDA	STARYP+3
SBC	STARY+1
STA	STARYP+3
LDX	#2
4$	LDA	STARYP,X
SBC	STARY	; sign extended
STA	STARYP,X
DEX
BPL	4$
LDX	#3
CLC
5$	LDA	STARY,X
TAY
ADC	STARYP,X
STA	STARY,X
STY	STARYP,X
DEX
BPL	5$

Some of the changes are because StarY is 9.16 bits, so the MSByte is either 0 or -1 ($FF). This means the -y[n]/64K can use that byte directly as a sign extend rather than having two branches. The rounding calculation is also much simpler, again no branching required. I also realized I didn't need an extra temporary variable.

 

Oh, I've also decreased the number of stars to those less than magnitude 5. I still can't pick out constellations though. FoV = 61 degrees horizontal, 42 degrees vertical which is fairly wide.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...