Path: news1.icaen!news.uiowa.edu!news1.chicago.iagnet.net!news2.chicago.iagnet.net!iagnet.net!howland.erols.net!nntprelay.mathworks.com!newsgate.duke.edu!news.eng.convex.com!egsner!news-feeder.onramp.net!news-f.iadfw.net!lpm2-22.atlcom.net!user From: sheldon@atlcom.net (Sheldon Simms) Newsgroups: comp.sys.apple2.programmer Subject: scrolling left (was Re: (no subject)) Date: Fri, 28 Nov 1997 23:46:59 -0500 Organization: none Lines: 100 Message-ID: X-Orig-Message-ID: References: <65nfut$8d9$1@mentor.telis.org> NNTP-Proxy-Relay: library.airnews.net NNTP-Posting-Time: Fri Nov 28 22:46:42 1997 NNTP-Posting-Host: lpm2-22.atlcom.net In article <65nfut$8d9$1@mentor.telis.org>, Pete wrote: > Just to show you I didn't want you to write my program for me: > Ok, I have it this far. The screen Scrolls!!! To the left even! > Problem: It scrolls the screen more than once! I'd like it to go once. Looking at your code I don't see why the screen would scroll left more than once unless you called it more than once. However, it seems to me that you are leaving part of the screen unscrolled. You scroll 22 lines (which ones are scrolled depends on the table) and scroll columns 1 through 37 of those lines into columns 1-36 - meaning that the right two columns and two whole lines never get scrolled at all. > other problems: I use the lookup table. This is slow, is there any other > way? How slow do you mean? A lookup table is a pretty fast way to access the Apple II video memory. Your code is a lot slower than it needs to be but still I imagine it would scroll the 40 column text screen so fast you couldn't see it. Am I mistaken? I don't understand why you have equates for your lookup table. This table should be in your code somewhere so you don't need equates. It's small enough that there's really no reason to compute it at run time. The biggest problem with your code is the XCNT and YCNT variables. You don't need them and using them slows your routine down. Use the X and Y registers to keep track of row and column. > > " ORG $0300" > "TEMPLO EQU $0004" > "TEMPHI EQU $0005" ; useless equate > "LOOKHI EQU $4000" > "LOOKLO EQU $4018" ; useless equate > "XCNT DRS 1" ; useless variable > "YCNT DRS 1" ; useless variable > " LDA #01" > " STA XCNT" > " LDA #01" > " STA YCNT" > "LOOPA LDY YCNT" ; 4 cycles > " LDA LOOKLO,Y" ; 4 cycles > " STA TEMPLO" ; 3 cycles > " LDA LOOKHI,Y" ; 4 cycles > " STA TEMPHI" ; 3 cycles > "LOOP LDY XCNT" ; 4 cycles > " LDA (TEMPLO),Y" ; 5 cycles > " DEY" ; 2 cycles > " STA (TEMPLO),Y" ; 6 cycles > " INC XCNT" ; 6 cycles > " LDA XCNT" ; 4 cycles > " CMP #38" ; 2 cycles > " BNE LOOP" ; 3 cycles = total 32 cycles > " INC YCNT" ; 6 cycles > " LDA YCNT" ; 4 cycles > " CMP #22" ; 2 cycles > " BNE LOOPA" ; 3 cycles = total 33 cycles > " RTS" > " EOF" I've counted the cycles in your routine above. 32 cycles in the inner loop give 32*40*24 = 30720 cycles for a full 40 column text screen scroll. 33 cycles in the outer loop gives 33*24 = 792 cycles for the routine for a total of 31512 cycles. On a 1Mhz Apple II that's almost 31 milliseconds. You shouldn't be able to see it scrolling each line. Below, I've taken your routine and just removed the XCNT and YCNT variables, using the X and Y registers for the same purpose. Counterintuitively, X is the row and Y is the column. temp equ $4 look dfw $0400, $0480, $500, $580, ... $7d0 scrolleft ldx #0 loopa ldy #1 ; 2 cycles lda look,x ; 4 cycles sta temp ; 3 cycles lda look+1,x ; 4 cycles sta temp+1 ; 3 cycles loop lda (temp),y ; 5 cycles dey ; 2 cycles sta (temp),y ; 6 cycles iny ; 2 cycles iny ; 2 cycles cpy #40 ; 2 cycles bne loop ; 3 cycles = total 22 cycles inx ; 2 cycles cpx #24 ; 2 cycles bne loopa ; 3 cycles = total 23 cycles rts Total for a full text screen scroll is 22*40*24 + 23*24 = 21672 cycles or, on a 1Mhz Apple II, about 21 milliseconds, a 45% speedup. -- W. Sheldon Simms III | 2000 is *still* the 20th century sheldon@atlcom.net | Path: news1.icaen!news.uiowa.edu!news1.chicago.iagnet.net!iagnet.net!newsfeed.internetmci.com!166.93.8.12!natasha.rmii.com!news1.rmi.net!not-for-mail From: Laine Houghton Newsgroups: comp.sys.apple2.programmer Subject: Re: scroll left (Pete) Date: 30 Nov 1997 15:06:53 GMT Organization: Rocky Mountain Internet - 1(800)-900-RMII Lines: 155 Message-ID: <65rved$4o5$1@news1.rmi.net> References: <65pq0p$1a$1@mentor.telis.org> NNTP-Posting-Host: shell.rmi.net User-Agent: tin/pre-1.4-971106 (UNIX) (SunOS/5.5 (i86pc)) Pete wrote: : I assembled the following program, SL.NATHAN : (scroll.left.nathan) Pete do you have a good Email address you could send me. A reply bounces. Anyway here is just another way to scroll left. It is down and dirty. There might be faster or more elegant way to do it but this is tested and working. Laine... LIST OFF KEEP TEST DRIVER START KEYPRS EQU $C000 KEYDATA EQU $C010 SCRN EQU $6 JSR $FC58 ;CLEAR HOME LDX #24 AGAIN DEX BEQ last LDY #$C0 LP INY CPY #$DB BNE CONT LDY #$E1 CONT CPY #$EF BEQ AGAIN TYA JSR $FDF0 ;FILL SCREEN WITH ALPHABET BNE LP LAST LDY #$27 LDA #$D0 STA SCRN LDA #7 STA SCRN+1 LDA #$AB LASTLP STA (SCRN),Y DEY BPL LASTLP KEY BIT KEYPRS BPL KEY LDA KEYDATA JSR SCROLL ;SCROLL ONE LEFT KEY1 BIT KEYPRS BPL KEY1 LDA KEYDATA STA (SCRN),Y ;DISPLAY LINE 23 COL 40 KEY2 BIT KEYPRS BPL KEY2 LDA KEYDATA RTS ;DONE TESTING SCROLL END **************************************************************** * * SCROLL ALL CHARS ONE TO THE LEFT IN 40 COL MODE. * * Inputs: NONE * * Outputs: A = 7 * Y = 0 * X = Unchanged * scrn = (scrn),y is line 23 col 40 * * NOTE: Cursor position is not altered. What ever it was on entry * it will be on exit. If you plan to use COUT to print to * the screen set the cursor to the desired location first. * **************************************************************** SCROLL START SCRN EQU $6 ;$6 $7 (ZERO PAGE), INDEX SHDOW EQU $8 ;$8 $9 " " LDA #0 STA SCRN LDA #4 ;START OF TEXT SCREEN STA SCRN+1 JSR LOOP LDA #$28 STA SCRN LDA #4 STA SCRN+1 LDY #0 LDA (SCRN),Y STA (SHDOW),Y JSR LOOP LDA #$50 STA SCRN LDA #4 STA SCRN+1 LDY #0 LDA (SCRN),Y STA (SHDOW),Y JSR LOOP LDY #0 LDA SHDOW STA SCRN LDA SHDOW+1 STA SCRN+1 RTS LOOP LDY #1 LP LDA (SCRN),Y DEY STA (SCRN),Y INY INY CPY #$28 BNE LP DEY TYA CLC ADC SCRN STA SCRN STA SHDOW LDA SCRN+1 ADC #0 STA SCRN+1 STA SHDOW+1 LDA SCRN ADC #$59 STA SCRN LDA SCRN+1 ADC #0 CMP #8 BNE SAFE RTS SAFE STA SCRN+1 LDY #0 LDA (SCRN),Y STA (SHDOW),Y LDA SCRN STA SHDOW LDA SCRN+1 STA SHDOW+1 JMP LOOP END Path: news1.icaen!news.uiowa.edu!news1.chicago.iagnet.net!iagnet.net!news.maxwell.syr.edu!news-was.dfn.de!newsjunkie.ans.net!newsfeeds.ans.net!news1.rmi.net!not-for-mail From: Laine Houghton Newsgroups: comp.sys.apple2.programmer Subject: scroll left Date: 1 Dec 1997 14:17:32 GMT Organization: Rocky Mountain Internet - 1(800)-900-RMII Lines: 129 Message-ID: <65ugts$gao$1@news1.rmi.net> NNTP-Posting-Host: shell.rmi.net User-Agent: tin/pre-1.4-971106 (UNIX) (SunOS/5.5 (i86pc)) I found 4 redundent instructons I was able to pull from the scroll routine. Still on a 1 meg machine it takes 20 miliseconds to scroll which is a little over 3 miliseconds slower then the VBL. Not a problem on the GS. Really not a problem on the // either since you would go cross-eyed changing screens at any where near that rate. LIST OFF KEEP TEST ******************************************************* * * left scrolling typewriter with NO support * for carrige returns and the like. * ****************************************************** DRIVER START KEYPRS EQU $C000 KEYDATA EQU $C010 SCRN EQU $6 JSR $FC58 ;CLEAR HOME KEY BIT KEYPRS BPL KEY JSR SCROLL ;SCROLL ONE LEFT lda keydata cmp #$9B ;escape beq quit STA (SCRN),Y ;DISPLAY LINE 23 COL 40 bne key quit rts END **************************************************************** * * SCROLL ALL CHARS ONE TO THE LEFT IN 40 COL MODE. * * Inputs: NONE * * Outputs: A = 7 * Y = 0 * X = Unchanged * scrn = (scrn),y is line 23 col 40 * * NOTE: Cursor position is not altered. What ever it was on entry * it will be on exit. If you plan to use COUT to print to * the screen set the cursor to the desired location first. * **************************************************************** SCROLL START SCRN EQU $6 ;$6 $7 (ZERO PAGE), INDEX SHDOW EQU $8 ;$8 $9 " " LDA #0 STA SCRN LDA #4 ;START OF TEXT SCREEN STA SCRN+1 JSR LOOP LDA #$28 STA SCRN LDA #4 STA SCRN+1 LDY #0 LDA (SCRN),Y STA (SHDOW),Y JSR LOOP LDA #$50 STA SCRN LDA #4 STA SCRN+1 LDY #0 LDA (SCRN),Y STA (SHDOW),Y JSR LOOP LDY #0 LDA SHDOW STA SCRN LDA SHDOW+1 STA SCRN+1 RTS LOOP LDY #1 LP LDA (SCRN),Y DEY STA (SCRN),Y INY INY CPY #$28 BNE LP DEY TYA CLC ADC SCRN STA SCRN STA SHDOW LDA SCRN+1 ADC #0 STA SCRN+1 STA SHDOW+1 LDA SCRN ADC #$59 STA SCRN LDA SCRN+1 ADC #0 CMP #8 BNE SAFE RTS SAFE STA SCRN+1 LDY #0 LDA (SCRN),Y STA (SHDOW),Y JMP LOOP END