Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Useless coding riddle: Stable raster without I/O
2014-11-12 08:59
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!
2014-11-12 09:01
chatGPZ

Registered: Dec 2001
Posts: 11127
extra points for using LAS and TAS! :o)
2014-11-12 09:13
Pex Mahoney Tufvesson

Registered: Sep 2003
Posts: 50
I think I can, but I'm not coding anything this time... Stop reading if you're not interested in my guesses... where's ROT13 when you need it? Ah, here it is! :)

Zl thrff vf gung lbh'er hfvat gur snpg gung n onqyvar jvyy unyg gur PCH qvssreragyl qrcraqvat ba jung nfz vafgehpgvba lbh'er pheeragyl qbvat. Fb, jevgr n ybbcrq pbqr jvgu gur rknpg nzbhag bs plpyrf ninvynoyr va n senzr - naq jevgr vg va fhpu jnl gung vg jvyy fybjyl "qevsg" gbjneqf gur "fgnoyr" cbfvgvba.

Correct?
---
Have a noise night!
http://mahoney.c64.org
2014-11-12 09:22
lft

Registered: Jul 2007
Posts: 369
@Pex: Yep, that's the gist of it.
2014-11-12 12:49
Flavioweb

Registered: Nov 2011
Posts: 447
;------------------------------------------------------------------------------- 
; Main stable raster routine
; (C) 2014 by FlavioWeb/Asura
;------------------------------------------------------------------------------- 
    *= $0801
    .WORD END_OF_PROGRAM
    .WORD 2014
    .BYTE $9E
    .TEXT "2061"
    .BYTE $00
END_OF_PROGRAM
    .WORD $0000
;-------------------
    SEI
WVB_01
    LDA $D011
    BMI WVB_01
WVB_02
    LDA $D011
    BPL WVB_02
;---------------------------------------
; Start raster IRQ alignment
;-------------------
    LDX $D012
IRQ_ALIGN_01
    CPX $D012
    BEQ IRQ_ALIGN_01
;-------------------
IRQ_ALIGN_02
    INX
    LDY #$0A
IRQ_ALIGN_03
    DEY
    BNE IRQ_ALIGN_03
IRQ_ALIGN_04
    CMP #$00
    CPX $D012
    BNE IRQ_ALIGN_02
    LDY #$0B
IRQ_ALIGN_05
    DEY
    BNE IRQ_ALIGN_05
    INC $D020                ; Here we are at cycle 58
    CLI
    RTS


Works on PAL.
(Sorry i'm hurry...)
=P
2014-11-12 12:50
chatGPZ

Registered: Dec 2001
Posts: 11127
err, did you understand what the point of lfts post was? o_O
2014-11-12 13:53
Zyron

Registered: Jan 2002
Posts: 2381
Obviously not. ;)
2014-11-12 14:13
Flavioweb

Registered: Nov 2011
Posts: 447
Ok.
Forgot my previous post.
'Without access I/O regs'.
2014-11-12 19:04
Slammer

Registered: Feb 2004
Posts: 416
Seams like the solution is combining Pex’s hint with actual code and some kind of induction proof that ensures it always ends in the desired end state instead of an endless drift.
2014-11-12 19:15
algorithm

Registered: May 2002
Posts: 702
I assume its probably using rmw instructions near/on badlines perhaps to remove jitter in stages?
2014-11-12 19:23
Danzig

Registered: Jun 2002
Posts: 429
cli jsr *
worx ;) proof: One Year Crest
 
... 14 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Clayboy
tlr
Freeze/Blazon
Guests online: 107
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 S!R  (9.7)
5 Faayd  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.046 sec.