AppleIIAsm-Collection/disks/disk2_common/T.DELAYMS
nathanriggs 875dd80998 stdio 0.2.0 updates
- fixed a bunch of bugs
- separated common and stdio libraries
- commenting upgrades
- created min versions of each library
2018-12-14 21:23:32 -05:00

82 lines
2.2 KiB
Plaintext

*
*``````````````````````````````*
* DELAYMS :: DELAY X MILLISECS *
*- -*
* DELAYS FOR X NUMBER OF *
* MILLISECONDS BY LOOPING *
* THROUGH PRECISELY CALCULATED *
* NUMBER OF CYCLES. *
*- -*
* CLOBBERS: *
* *
* FLAGS: ????---- REG: -XY- *
*- -*
* CYCLES: ??? *
* SIZE: *
*- -*
* USAGE: *
* *
* LDY #250 ;1/4 SEC *
* JSR DELAYMS *
*- -*
* ENTRY *
* *
* Y = NUMBER OF MILLISECONDS *
*- -*
* EXIT *
* *
* Y = COUNTER; TRASH *
* X = COUNTER; TRASH *
* A = UNCHANGED *
*- -*
* ADAPTED FROM LEVANTHAL AND *
* WINTHROP'S /6502 ASSEMBLY *
* LANGUAGE ROUTINES/. *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
DELAYMS
*
MSCNT EQU $0CA ; 202 TIMES THROUGH DELAY1
; SPECIFIC TO 1.23 MHZ
; SPEED OF APPLE II
:DELAY
CPY #0 ; 2 CYCLES
BEQ :EXIT ; 2C (EXIT IF DEL=0)
NOP ; 2 CYCLES (MAKE OVERHEAD=25C)
*
** IF DELAY IS 1MS THEN GOTO LAST1
** THIS LOGIC IS DESIGNED TO BE
** 5 CYCLES THROUGH EITHER ATH
*
CPY #1 ; 2 CYCLES
BNE :DELAYA ; 3C IF TAKEN, ELSE 2C
JMP :LAST1 ; 3C
*
** DELAY 1 MILLISENCOND TIMES (Y-1)
*
:DELAYA
DEY ; 2C (PREDEC Y)
:DELAY0
LDX #MSCNT ; 2C
:DELAY1
DEX ; 2C
BNE :DELAY1 ; 3C
NOP ; 2C
NOP ; 2C
DEY ; 2C
BNE :DELAY0 ; 3C
:LAST1
*
** DELAY THE LAST TIME 25 CYCLES
** LESS TO TAKE THE CALL, RETURN,
** AND ROUTINE OVERHEAD INTO
** ACCOUNT.
*
LDX #MSCNT-3 ; 2C
:DELAY2
DEX ; 2C
BNE :DELAY2 ; 3C
:EXIT
RTS ; 6C
*