Yaron Nir Posted April 13, 2019 Share Posted April 13, 2019 Is there a built in CC65 routine to wait uppon WSYNC event? i saw a method called waitvsync() which is exactly what i was looking for but it is not supported in Atari CC65 i also saw some threads for comparing ANTIC.vcount with something to determine if a WSYNC has occured. want to use an already tested and proved built in routine thanks Quote Link to comment Share on other sites More sharing options...
Xuel Posted April 13, 2019 Share Posted April 13, 2019 You can just write any value to WSYNC: __asm__ ("sta $D40A"); If you want to guarantee the next instruction starts on exactly cycle 105, then you can INC WSYNC as long as you know the INC will occur complete by cycle 103: __asm__ ("inc $D40A"); Altirra Hardware Reference Manual exceprt: 4.9 WSYNC A write to WSYNC [D40A] halts CPU execution until the end of a scan line, allowing the CPU to synchronize to the display. 1 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted April 13, 2019 Share Posted April 13, 2019 I suspect you want to wait for the end of a frame: WaitForSync: Loop1: lda VCount bne Loop1: Loop2: lda VCount beq Loop2: rts 1 Quote Link to comment Share on other sites More sharing options...
Xuel Posted April 13, 2019 Share Posted April 13, 2019 Rereading your message, looks like you may be mixing terms. WSYNC is for scan line synchronization while VSYNC and VCOUNT would be for vertical blank synchronization. What is your use case? If you just want to wait for the vertical blank, then you can loop on RTCLOK: char *jiffies, prev; jiffies = (char*)20; prev = *jiffies; while (prev == *jiffies) ; /* synced to vblank here */ 1 Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted April 13, 2019 Author Share Posted April 13, 2019 So, indeed I was referring to vblank as i wish to do the main loop thing on each frame I was looking for a built in solution in CC65 but couldnt find one. All the suggested above I am familiar with Another idea is to compare ANTIC.vcount to 124 and by that identify that vcount has occur So was looking for something that was already written and tested in C (CC65) Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted April 13, 2019 Share Posted April 13, 2019 Utilise either of the Immediate or Deferred Vblank hooks: #include <atari.h> #define SETVBV 0xE45C #define SYSVBV 0xE45F void MyVbi() { OS.color4++; asm("jmp %w", SYSVBV); } void SetVbi() { asm("ldx #>%v", MyVbi); asm("ldy #<%v", MyVbi); asm("lda #6"); asm("jsr %w", SETVBV); } int main() { SetVbi(); while (1); return 0; } Those system vectors are probably a good candidate for adding into _atarios.h Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted April 14, 2019 Author Share Posted April 14, 2019 Wrathchild Tnx Maybe you can contribute and add it to atarios? Quote Link to comment Share on other sites More sharing options...
Irgendwer Posted April 14, 2019 Share Posted April 14, 2019 Those system vectors are probably a good candidate for adding into _atarios.h Maybe it's important to mention that the code of your "MyVbi"-function is restricted in using C functionality. Accessing the C-stack as well as many library function will break the main-land program - so to make the usage somewhat safe I would prefer a more "prepared"-way to offer IRQ-"sub-routines". Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted April 14, 2019 Share Posted April 14, 2019 Indeed, keeping it simple within the VBI is wise.No harm in calling functions with no arguments and void return if you need to break things into manageable steps. You can also include call-outs to asm routines, for example the RMT player's VB play routine. The VB interrupt is already covered by pushing the registers which are restored if exited properly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.