"Vaporlock" technique from Don Lancaster's Enhancing Your Apple II and IIe

4 posts / 0 new
Last post
Offline
Last seen: 11 months 1 week ago
Joined: May 20 2020 - 00:17
Posts: 5
"Vaporlock" technique from Don Lancaster's Enhancing Your Apple II and IIe

I was reading about Don Lancaster's "Vaporlock" technique for finding the exact timing of the vertical blank during screen refreshes.   Does anyone happen to have the sourcecode available or know where I can find the companion disk that came with Enhancing Your Apple II and IIe I am hoping to avoid typing everything in manually

mmphosis's picture
Offline
Last seen: 2 days 18 hours ago
Joined: Aug 18 2005 - 16:26
Posts: 385
Wow. Thanks for pointing this out

In the mid-80's through word of mouth, I played around with (LDA $C050) what is referred to as the "floating bus", although at the time I didn't know that term. Much much later, I found Bob Bishop's article "Have an Apple Split" from Softalk, October 1982, and others have similar programs that use the floating bus. 

Here is my quick one-liner to see a horizontal video effect:

300:AD 50 C0 EA AD 51 C0 4C 0 3 N 300G

This needs to be run from the MONitor on a real Apple II, or with a cycle accurate emulator like AppleWin, Epple ][, KEGS, ...

 

I've heard others use the term "vaporlock", so regarding Don Lancaster's book, I was able to find a few things ...

The book on Don Lancaster's web site:

https://www.tinaja.com/ebooks/enhance_vII.pdf

page 204 Enhancement 13 PROGRAM 13-1 Listing of VAPORLOCK.SOURCE.

 

A disk with the VAPORLOCK binary program without the source code:

https://archive.org/download/d181s1-mon-rom-vaporlock/d181s1-mon-rom-vaporlock.dsk

 

 

 

 

 

MarkO's picture
Offline
Last seen: 2 weeks 5 days ago
Joined: Dec 10 2011 - 16:26
Posts: 680
"Vaporlock" technique from Don Lancaster's Enhancing Your Apple

Bob Bishop, ( of Apple Vision fame ), has also done some work on this "quirk" of the Apple ][..

 

See: Have an Apple Split

and : Apple II Vapor Lock and the Floating Bus

 

Don Lancaster's other books are a great read.   I would read each of his Articles in the Computer Shopper, back in the 1980's...

 

Also checkout Vince Weaver's Demo that uses this techneque: Apple II 64k Cycle Counting Megademo

 

 

MarkO

 

 

 

 

 

 

 

S.Elliott's picture
Offline
Last seen: 2 hours 21 min ago
Joined: Jun 23 2022 - 16:26
Posts: 28
Interactive vapor lock -- WINDOWTOGGLE.OBJ0 with source code

I've been experimenting with that kind of stuff all month, but I didn't know it was called "vapor lock".

WINDOWTOGGLE isn't very pretty, but it's surprisingly satisfying to play with.  It divides the screen into ten 4-character-wide windows that can be independently switched betwen graphics mode and text mode.

I posted a variant of WINDOWTOGGLE in the Apple II Enthusiasts group on Facebook.  Apparently it's a useful test case, as developers of  Accurapple and AppleWin asked me to share the source code on Slack.

Either assemble the program and start it with BRUN WINDOWTOGGLE.OBJ0, or enter the machine code in the monitor and start it with 300G

 

Press the keys 0-9 to switch each region between text or graphics.

Here's a machine-code listing:

0300:20 69 03 AD 57 C0 AD 54

0308:C0 AD 52 C0 AD 50 C0 AD

0310:50 C0 10 FB 24 06 EA 4C

0318:26 03 CD 50 C0 CD 50 C0

0320:CD 50 C0 CD 50 C0 CD 50

0328:C0 CD 50 C0 CD 50 C0 CD

0330:50 C0 CD 50 C0 CD 50 C0

0338:CD 50 C0 CD 50 C0 CD 56

0340:C0 CD 53 C0 EA AD 00 C0

0348:10 D0 C9 9B D0 01 60 29

0350:0F EA 2C 10 C0 85 3D 0A

0358:38 65 3D AA BD 1A 03 69

0360:01 29 F1 9D 1A 03 D0 D0

0368:60 A9 20 85 E6 85 3D A9

0370:40 85 3F A0 00 84 3C 84

0378:3E B1 3C 29 7F 91 3C 20

0380:B4 FC 90 F5 A9 40 85 3C

0388:85 3D A5 3C 20 11 F4 A0

0390:00 B1 26 09 80 91 26 E6

0398:3C C6 3D D0 ED B9 A9 03

03A0:F0 06 20 F0 FD C8 D0 F5

03A8:60 8D D0 D2 C5 D3 D3 A0

03B0:CB C5 D9 D3 A0 B0 AD B9

03B8:00 

And the ASM source:

SOURCE   FILE: WINDOWTOGGLE 

----- NEXT OBJECT FILE NAME IS WINDOWTOGGLE.OBJ0             

0300:        0300    1           ORG   $300

0300:                2 * 65-cycle color killer 0300:                3 *

0300:                4 * This polls for screen byte #$80 or hires alternate-black.. 

0300:                5 * Then it uses a 65-cycle loop to split the screen into vertical strips. 

0300:                6 *

0300:                7 ; ** BIOS locations **

0300:        003C    8 A1L       EQU   $3C

0300:        003D    9 A1H       EQU   $3D

0300:        003E   10 A2L       EQU   $3E

0300:        003F   11 A2H       EQU   $3F

0300:        FCB4   12 NXTA1     EQU   $FCB4         ; routine to increment (A1) and compare (A2)

0300:               13 ;

0300:        0026   14 HBASL     EQU   $26           ; hires base address (low byte)

0300:        F411   15 HPOSN     EQU   $F411         ; set HBASL to base address of HGR line in A

0300:        00E6   16 HGRPAGE   EQU   $E6           ;base address ($20 or $40)

0300:        0024   17 MONCH     EQU   $24           ;cursor horizontal position

0300:        FDF0   18 COUT1     EQU   $FDF0         ; character output to screen

0300:               19 *

0300:               20 ; ** Screen soft switches ** 

0300:        C050   21 TEXTOFF   EQU   $C050

0300:        C051   22 TEXTON    EQU   $C051

0300:        C052   23 MIXEDOFF  EQU   $C052

0300:        C053   24 MIXEDON   EQU   $C053

0300:        C054   25 PAGE1     EQU   $C054

0300:        C055   26 PAGE2     EQU   $C055

0300:        C056   27 LORES     EQU   $C056

0300:        C057   28 HIRES     EQU   $C057

0300:               29 * 

0300:20 69 03       30 INIT      JSR   HISCRUB       ; start by scrubbing the HGR screen

0303:               31 ;

0303:AD 57 C0       32 FINDSYNC  LDA   HIRES         ;Choose hi resolution mode

0306:AD 54 C0       33           LDA   PAGE1         ;Default to page 1

0309:AD 52 C0       34           LDA   MIXEDOFF      ;text window off until sync acquired 

030C:AD 50 C0       35           LDA   TEXTOFF       ; scan must occur in graphics mode 

030F:               36 ;

030F:               37 * Various find loops - all but 1 commented out at a time 

030F:               38 * 1. FIND HIGH BIT for graphics without half-dot-shift

030F:               39 ;

030F:AD 50 C0       40 FINDLOOP  LDA   TEXTOFF

0312:10 FB   030F   41           BPL   FINDLOOP      ; keep searching if high bit isn't set

0314:               42 ;

0314:               43 * 2. FIND ALTERNATE BLACK for #$80 in first column

0314:               44 ; LDA #$80

0314:               45 ;FINDLOOP CMP TEXTOFF

0314:               46 ; BNE FINDLOOP ;keep searching if it doesn't match yet

0314:               47 ;

0314:24 06          48           BIT   6             ; 3 cycles

0316:EA             49           NOP                 ; 2 cycles

0317:4C 26 03       50           JMP   P16           ;JMP 16 cycles inside loop

031A:               51 ;

031A:CD 50 C0       52 SYNCLOOP  CMP   TEXTOFF       ;Cols 00 01 02 03 

031D:CD 50 C0       53 P04       CMP   TEXTOFF       ;     04 05 06 07 

0320:CD 50 C0       54 P08       CMP   TEXTOFF       ;     08 09 10 11 

0323:CD 50 C0       55 P12       CMP   TEXTOFF       ;     12 13 14 15 

0326:CD 50 C0       56 P16       CMP   TEXTOFF       ;     16 17 18 19 

0329:CD 50 C0       57 P20       CMP   TEXTOFF       ;     20 21 22 23  

032C:CD 50 C0       58 P24       CMP   TEXTOFF       ;     24 25 26 27 

032F:CD 50 C0       59 P28       CMP   TEXTOFF       ;     28 29 30 31 

0332:CD 50 C0       60 P32       CMP   TEXTOFF       ;     32 33 34 35 

0335:CD 50 C0       61 P36       CMP   TEXTOFF       ;     36 37 38 39  

0338:CD 50 C0       62 P40       CMP   TEXTOFF       ;     .. .. .. .. 

033B:CD 50 C0       63 P44       CMP   TEXTOFF       ;     HBL 

033E:CD 56 C0       64 P48       CMP   LORES         ;     HBL 

0341:CD 53 C0       65 P52       CMP   MIXEDON       ; last switch until next line 

0344:EA             66           NOP                 ;[2] + 38 = 3A 

0345:AD 00 C0       67           LDA   $C000         ;[4] + 3A = 3E 

0348:10 D0   031A   68           BPL   SYNCLOOP      ;[3] + 3E = 41 

034A:C9 9B          69           CMP   #$9B          ;[3] was 'esc' pressed?

034C:D0 01   034F   70           BNE   TOGGLE        ;[3] no, branch to toggle routine

034E:60             71           RTS

034F:               72 ;

034F:29 0F          73 TOGGLE    AND   #$0F          ;[2] restrict to range 0-F 

0351:               74 ; do a couple of timing adjustments

0351:EA             75           NOP                 ;burn 2 cycles to help sync again

0352:               76 ;BIT 6 ;burn 3 cycles to help sync again

0352:2C 10 C0       77           BIT   $C010         ; clear keyboard

0355:85 3D          78           STA   A1H           ; store in memory for arithmetic

0357:0A             79           ASL   A             ; A = keycode * 2

0358:38             80           SEC                  ; set carry for next instruction 

0359:65 3D          81           ADC   A1H           ; A = (keycode * 3) + 1

035B:AA             82           TAX                  ; move index to X reg

035C:BD 1A 03       83           LDA   SYNCLOOP,X    ;get low-order byte of a SYNCLOOP instruction

035F:69 01          84           ADC   #1            ;increment low nybble 

0361:               85 ** Choose only 1 of the next 2 lines, comment-out the other **

0361:29 F1          86           AND   #$F1          ; cycle through 2 switches only 

0363:               87 * AND #$F7 ; cycle through all 8 switches 

0363:9D 1A 03       88           STA   SYNCLOOP,X    ;update low-order byte

0366:D0 D0   0338   89           BNE   P40           ;branch to 40-cycles-into-loop 

0368:60             90           RTS

0369:               91 ;

0369:               92 * Scrub high bits out of hires memory

0369:               93 ;

0369:A9 20          94 HISCRUB   LDA   #$20

036B:85 E6          95           STA   HGRPAGE       ;Set HGR page address

036D:85 3D          96           STA   A1H           ;Set (A1) to start address

036F:A9 40          97           LDA   #$40

0371:85 3F          98           STA   A2H           ;Set (a2) to end address

0373:A0 00          99           LDY   #0

0375:84 3C         100           STY   A1L

0377:84 3E         101           STY   A2L

0379:B1 3C         102 MASKLOOP  LDA   (A1L),Y       ; read next byte 

037B:29 7F         103           AND   #$7F          ; remove high bit

037D:91 3C         104           STA   (A1L),Y       ; store it back

037F:20 B4 FC      105           JSR   NXTA1

0382:90 F5   0379  106           BCC   MASKLOOP

0384:              107 ;

0384:              108 * Now add a high bit to 64 bytes in a column starting at line 64

0384:              109 ;

0384:A9 40         110           LDA   #64           ; start at line 64

0386:85 3C         111           STA   A1L           ; current line

0388:85 3D         112           STA   A1H           ; current count

038A:A5 3C         113 DEMASKLOOP LDA  A1L

038C:20 11 F4      114           JSR   HPOSN

038F:A0 00         115           LDY   #0

0391:B1 26         116           LDA   (HBASL),Y

0393:09 80         117           ORA   #$80          ; add high bit 

0395:91 26         118           STA   (HBASL),Y

0397:E6 3C         119           INC   A1L

0399:C6 3D         120           DEC   A1H

039B:D0 ED   038A  121           BNE   DEMASKLOOP

039D:              122 ;

039D:              123 ; Print message at MSGTEXT 

039D:B9 A9 03      124 MSGLOOP   LDA   MSGCR,Y

03A0:F0 06   03A8  125           BEQ   MSGDONE

03A2:20 F0 FD      126           JSR   COUT1

03A5:C8            127           INY

03A6:D0 F5   039D  128           BNE   MSGLOOP

03A8:              129 ;

03A8:60            130 MSGDONE   RTS

03A9:              131 ;

03A9:8D            132 MSGCR     DB    $8D           ;carriage return

03AA:D0 D2 C5 D3   133 MSGTEXT   ASC   "PRESS        KEYS 0-9"

03B8:00            134           DB    0

   3D A1H              3C A1L              3F A2H              3E A2L           

 FDF0 COUT1          038A DEMASKLOOP     030F FINDLOOP      ?0303 FINDSYNC      

   26 HBASL            E6 HGRPAGE        C057 HIRES          0369 HISCRUB       

 F411 HPOSN         ?0300 INIT           C056 LORES          0379 MASKLOOP      

 C052 MIXEDOFF       C053 MIXEDON       ?  24 MONCH          03A9 MSGCR         

 03A8 MSGDONE        039D MSGLOOP       ?03AA MSGTEXT        FCB4 NXTA1         

?031D P04           ?0320 P08           ?0323 P12            0326 P16           

?0329 P20           ?032C P24           ?032F P28           ?0332 P32           

?0335 P36            0338 P40           ?033B P44           ?033E P48           

?0341 P52            C054 PAGE1         ?C055 PAGE2          031A SYNCLOOP      

 C050 TEXTOFF       ?C051 TEXTON         034F TOGGLE        

** SUCCESSFUL ASSEMBLY := NO ERRORS

** ASSEMBLER CREATED ON 21-MAY-83 REL-07

** TOTAL LINES ASSEMBLED   134 

** FREE SPACE PAGE COUNT   77 

 

Is there a better way to post source code here?  The [code] and <code> tags apparently don't work.

Log in or register to post comments