Aces123 Posted April 14, 2015 Share Posted April 14, 2015 I have written this program that writes hello and fills the screen with blank spaces again. I want to make a loop so that it first writes, then pauses for a while, writes the blank spaces, pauses for a while and then returns to the beginning. How do I do that? org $3000 pla lda #$28 sta $9c40 lda #$25 sta $9c41 lda #$2c sta $9c42 sta $9c43 lda #$2f sta $9c44 lda #$0 sta $9c40 sta $9c41 sta $9c42 sta $9c43 sta $9c44 end I am using mads, but I would prefer if the solution is as 'native' as possible. So that it is easy to implement with another assembler as well. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Aces123 Posted April 14, 2015 Author Share Posted April 14, 2015 By the way the atari crashes after a while in the end. Is there something else I should add to the code? Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted April 14, 2015 Share Posted April 14, 2015 (edited) You could use the real time clock to idle for a while. This will pause for around a second: lda $14 clc adc #200 PauseLoop cmp $14 bne PauseLoop Is your code called from BASIC via USR? If not, you don't need the PLA at the top (although I'm assuming this is a USR routine). You need RTS at the end to return to the caller, or an empty loop if you just want to stop after printing: jmp * To return to the start, meanwhile, add a label at the top of the code and at the end add: jmp label_name Edited April 14, 2015 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
Aces123 Posted April 14, 2015 Author Share Posted April 14, 2015 Thanks! I took me a while to realize that I needed two loops but when I finaly understood it worked like charm . What would be the best way to go about it if I wanted to have greater control over how long the computer pauses? In Basic I would use a for loop but in assembler I have no idea Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted April 14, 2015 Share Posted April 14, 2015 (edited) Since assembler runs magnitudes faster than BASIC, it's more difficult to create meaningful pauses without lots of nested loops. So you can fine tune that pause using the RTC, for example, by changing the value after the ADC instruction. The counter runs from 0-255, one tick per vertical blank, so that's 50 times a second for PAL, 60 for NTSC. So if you wanted a two second delay under NTSC, 255-120 = 135, so "ADC #135". For much longer delays, you could think about using the next most significant byte of the 3-byte real time clock at $13, which counts over around once every five seconds. Edited April 14, 2015 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
Aces123 Posted April 15, 2015 Author Share Posted April 15, 2015 (edited) Thanks! I wanted to have a shorter delay, but when I changed adc to 250 it turned out that this increased the length of the pause. But when I changed adc to 10 I got what I wanted Edited April 15, 2015 by Aces123 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted April 15, 2015 Share Posted April 15, 2015 (edited) Sorry I got the calculation arse about front. Just add the number of jiffies you want to wait. D'oh! Edited April 15, 2015 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 17, 2015 Share Posted April 17, 2015 haha... just thought I worked wrong 25 years with VBL counters... (thinking of my pain syncing Arsantica 3 Intro ) but well... good to know that I was ok Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted April 17, 2015 Share Posted April 17, 2015 I think the solder fumes are getting to me. 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.