Jump to content
IGNORED

pixels per second in Antic $0D


Recommended Posts

That's the joy of 6502. Code is never "definitive". :)

This thread continues to deliver. That's really true about 6502...it's something about the balance between limitations and capability that is just at a perfect point. I have noticed that the pleasures of many endeavors are based on the limitations, and not the capabilities. If it's too easy, its not interesting, and if it's too hard it's not interesting either.

  • Like 1
Link to comment
Share on other sites

Could you elaborate these three things ?

 

I think he means something like

 

ldx offsetInTable

stx lowByteOfTable

 

lda table,x

lowByteOfTable = * -2

 

to have a two byte offset access. Normally it is faster (and ROM compatible) to separate hi and low bytes to different tables, but this is not an option for jump-addresses.

Edited by Irgendwer
  • Like 2
Link to comment
Share on other sites

Could you elaborate these three things ?

WordTable equ $1000 ;page aligned
WordPtr equ $f0

lda >#WordTable ;init
sta WordPtr+1 ;init
ldy byteindex
sty WordPtr
lda (WordPtr),y ;y+y == 2*y
iny
lda (WordPtr),y ;second byte of word

Or a SMC variation. But this makes more sense on a cpu that can do word accesses.

 

The next one is more primitive

ldx IndexByte
lda JumpOffset,x ;4?
sta JumpSMC+1 ;4?
JumpSMC:
jmp JumpLabel ;3

cnop 0,256 ;page align
JumpLabel:
jmp byte0 ;3
jmp byte1
...
jmp byte85

JumpOffset:
dc .b 0*3
dc.b 1*3
dc.b 2*3
...
dc.b 85*3

byte0:
; code for index 0 starts here

Which is a byte-size indexed jump in 14 cycles. For the full 0-255 range it takes 19 cycles SMC (20 using non-SMC stack).

 

For the sorting in Tyger Tyger it is basically a massive cheat that looks a little bit like this

lda Y_position
lsr
tax
txs
loop:
pla
bmi loop

then stuff your sort index on the stack with a pha

The idea is to just search for free slots on the stack where you can insert your array index and hope that things gets reasonably in order, and when you are done you can pop the stack and easily get your objects. Kind of a bucket sort? Insertion sort? Radix sort? Very much a case of "good enough".

See thread that uses it here: http://www.lemon64.com/forum/viewtopic.php?t=5839

 

I guess you have seen Linus' loader info. For reference Linus' own page on it http://www.linusakesson.net/programming/gcr-decoding/index.php

Edited by NorthWay
  • Like 1
Link to comment
Share on other sites

Cool trick with "doubling by indexing"! Never thought of using that for reaching two byte tables.

Funny considering I've used it in a more general case of using "indexing for adding".

Table at AA00 and LDA AABB,x for calculating f(BB+x).

 

Must admit my jump table approaches were at least 3 cycles slower :)

Will remember that for when it's needed.

 

Thanks for reminding us on that stack based sprite sorting method.

Found more info here: http://www.c64.com/interviews/hughes.html

"Basically, all the Y split positions were indexed directly into to stack memory. I could then easily do a quick insertion sort by setting the point of insertion into the stack pointer and then pushing the position in the list – the stack magically took care of the rest."

 

And yeah 1541 loader is also a great example of 6502 coding.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...