| |
lft
Registered: Jul 2007 Posts: 369 |
Useless coding riddle: Stable raster without I/O
Hi!
I came up with a technique to synchronise code to the raster position without accessing any I/O registers. It is not very efficient, and hence not very useful, but it was a nice intellectual exercise.
This is the premise: Provide a small piece of code (less than a page) that may start executing at any time. When execution reaches the end of the code, the current rasterline and cycle will be known. You may assume that sprites and interrupts are off, and that d011 has its default value (9b).
See if you can figure out how it's done! |
|
... 20 posts hidden. Click here to view all posts.... |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
This is my last one, I don't want to flood the thread. :)
It uses brk and converges a bit faster: 262 frames, about 5.2s.
Too bad that I couldn't bring it down to 256 or less...
One more thought: adding other misaligned write cycles, even though it doesn't ruin the sync process, has the side effect of slowing it down because those writes get "randomly" absorbed by the badlines.
http://pastebin.com/rLNaayPz
(63 bytes) |
| |
ruk
Registered: Jan 2012 Posts: 43 |
@lft: Brilliant as always :) I would never have thought of using JSR in favour of a plain old INC. 10/10 |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
For the record, Quiss's method with Copyfault's refinements solves the problem in 8 bytes, so it does have useful properties for sizecoding. =) |
| |
Copyfault
Registered: Dec 2001 Posts: 478 |
Quoting KrillFor the record, Quiss's method with Copyfault's refinements solves the problem in 8 bytes, so it does have useful properties for sizecoding. =) Oh nice, thanks Krill for the mention. This brought the whole thread here to my notice for the first time, so I really *do* wonder how this could have slipped through my radar for coding riddles.
Nice approaches in here, so thanks also for the pointer! |
Previous - 1 | 2 | 3 - Next |