Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #2581

Re: Slowing Down an Assembly Program

Newsgroups comp.sys.apple2.programmer
Date 2016-03-23 12:45 -0700
References <d6a08ee7-2108-43bc-a4b3-290465826474@googlegroups.com>
Message-ID <042da2df-523b-4cdb-8aae-72fed8499cb4@googlegroups.com> (permalink)
Subject Re: Slowing Down an Assembly Program
From Michael Pohoreski <michael.pohoreski@gmail.com>

Show all headers | View raw


On Wednesday, March 23, 2016 at 10:37:25 AM UTC-7, alx...@aol.com wrote:
> I am working on a learning project that prints out the alphabet in ascending and descending order. It works, but is so fast! How can you slow down an assembly language program? 

There are 2 general solutions:

1. Use multiple nested loops and "busy wait"
1a) Write your own with manual cycle accurate timing

delay   LDX #n
waitx   LDY #0
waity   DEY
        BNE waity
        DEX
        BNE waitx

1b) Call the Monitor ROM

2. Wait for VSync. On the Apple 2 this is commonly mislabeled RDVBL; the correct name is RDVBLBAR -- ReaD VBLank AddRess

i.e.

        RDVBLBAR	        = $C019 ; *not* RDVBL (VBL signal low)

Delay:  STY $4FF            ; temp, change to your needs
        LDY #10             ; 10 is about 3/4 second
_Delay:
        JSR VSyncNEG
        JSR VSyncPOS
        DEY
        BNE _Delay
        LDY $4FF
        RTS
VSyncPOS:
        LDA RDVBLBAR
        BPL VSyncPOS
        RTS
VSyncNEG:
        LDA RDVBLBAR
        BMI VSyncNEG
        RTS


Comp:  O = Apple II+  E = Apple IIe  C = Apple IIc  G = Apple IIgs
Act:   R = Read       W = Write      7 = Bit 7      V = Value

Address    Name         Comp Act  Description

C019 49177 RDVBL         E G  R7  Vertical Blanking (E:1=drawing G:0=drawing)

References:

* http://www.kreativekorp.com/miscpages/a2info/iomemory.shtml
* http://paperity.org/p/18929044/screen-display-and-timing-synchronization-on-the-apple-iie-and-apple-ilgs

Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Slowing Down an Assembly Program alxmist@aol.com - 2016-03-23 10:37 -0700
  Re: Slowing Down an Assembly Program AppleIIGSMarc <appleiigsmarc@gmail.com> - 2016-03-23 12:23 -0700
  Re: Slowing Down an Assembly Program Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-23 12:45 -0700
    Re: Slowing Down an Assembly Program AppleIIGSMarc <appleiigsmarc@gmail.com> - 2016-03-23 13:14 -0700
      Re: Slowing Down an Assembly Program Michael Pohoreski <michael.pohoreski@gmail.com> - 2016-03-23 14:37 -0700

csiph-web