Login
Back to forumReply to this topicGo to last reply

Posted By

icbrkr
on 2014-10-28
21:10:38
 general smooth scrolling questions

I'm still learning some assembly, and TED, so I'm going to keep asking questions happy

I'm looking at the code that came with the Plus 4 IDE compiler (which unfortunately, doesn't seem to run right in Windows 8) but I was able to recompile it into CBM Program Studio.

One of the sample pieces gives a sample raster and scrolling text. While this works great on PAL, it does not work on NTSC quite right. I set TED to NTSC, and within Yape it displays properly, but on a real NTSC Plus/4 the lower few lines of the screen scrambles like it's losing sync.. basically anything from the raster bar downwards.

My thought is that it has something to do with the screen being shorter in NTSC mode and it's trying to draw off the screen before setting $FF07 back to its original position...

Part of the code looks like this:


;Initializing


HorizPos = $10 ; variables
ScrollCount = $E1
ScrollPos = $0f70 ; Screen Position




irq

PHA ; save A
TXA
PHA ; save X
TYA
PHA ; save Y
;
LDA $FF09 ; clear interrupt bit
STA $FF09



; (2) adjust horiz scroll TED register
;
LDA HorizPos ; *** get our VARIABLE ***
STA $FF07 ; change FF07 (horiz scroll)
;
; (3) do "rasterbar"
;
LDX #17 ; 18 colors
LDY #$a8 ; VERTICAL POSITION check **
loop06 LDA Colors,x ; get next color
loop05 CPY $FF1E ; wait for vertical pos **
BCS loop05 ; keep waiting **

STA $FF19 ; change BORDER and...
STA $FF15 ; background color
DEX
BPL loop06
;
; (4) restore color and scroll regs.
;
LDA #$58 ; *** Return to "normal" horiz position
STA $ff07
;
; (5) do the scroll work!
;
; --- increment scroll variable
;
LDX HorizPos ; get value of our variable
DEX ; decrement by one
BPL loop07 ; positive? ( >= 0)
; ; then that's it for this loop...




; otherwise:
; --- copy characters on screen
; only every 8th time
;
LDX #$00
loop08 LDA ScrollPos+1,X
STA ScrollPos,X
INX
CPX #$27
BNE loop08
;
; --- put NEW character onto screen
;
LDX ScrollCount
loop10 LDA ScrollText,X ; read scroll text
CMP #$FF ; end flag?
BNE loop09
;
LDX #$00 ; restart from 0
JMP loop10
;
loop09 CMP #$40
BCC put2
AND #$1F
put2 STA ScrollPos+39 ; LAST POSITION in our line
INX ; next letter
STX ScrollCount
;
LDX #$07 ; next value
loop07 STX HorizPos ; store it



;
; --- end of IRQ
;
PLA
TAY ; restore Y
PLA
TAX ; restore X
PLA ; restore A

RTI ; Return from Interrupt

Basically, it looks like it works fine if I comment out (except smooth scrolling no longer works):


loop05 CPY $FF1E ; wait for vertical pos **
BCS loop05 ; keep waiting **


or any loop that's waiting for the screen positioning.

Since I'm still a newbie, I'm at a loss on how to 'fix' this.

Posted By

Luca
on 2014-10-29
06:07:57
 Re: general smooth scrolling questions

Hi there icbrkr (Icebreaker?)!

I could propose slight changes to your code:
- raster's vertical positioning is $FF1D, $FF1E is the horizontal one, it can be used too, but in a different way (if I got well what you're trying to do there...)
- should it be an INY there in order to try further positions of the raster?
; (3) do "rasterbar"
;
ldx #17 ; 18 colors
ldy #$a8 ; vertical position check **
loop06 lda colors,x ; get next color
loop05 cpy $ff1d ; wait for vertical pos **
bcs loop05 ; keep waiting **
sta $ff19 ; change border and...
sta $ff15 ; background color
iny
dex
bpl loop06


These changes would take you to change the #$a8 value for vertical checking in order to stay on the target text, and probably you'll have to add some NOPs in order to fine tuning it. Just try arguing, take it as chitchatting wink

Posted By

gerliczer
on 2014-10-29
12:32:22
 Re: general smooth scrolling questions

Hi icbrkr,

I'd suggest to compare the following code snippets:
LDA HorizPos ; *** get our VARIABLE ***
STA $FF07 ; change FF07 (horiz scroll)
==============================
LDA #$58 ; *** Return to "normal" horiz position
STA $ff07
==============================
LDX #$07 ; next value
loop07 STX HorizPos ; store it


Guesswork: by the symptoms you described, you are turning on PAL mode when you try to set the scroll position. (It is a good question why does this not bother YAPE?)

Posted By

Gaia
on 2014-10-29
13:05:44
 Re: general smooth scrolling questions

TV emulation still s**x in Yape... I have the ambition to fix this... so it's just a matter of time wink

Posted By

icbrkr
on 2014-10-29
19:05:21
 Re: general smooth scrolling questions

Thanks for the suggestions.

I might have cut and pasted something wrong (I was doing a lot of code tweaking), but HorizPos's default value is $E0, which would set bit 6 high on $FF07. If I'm reading this right, it would set it to NTSC and turn off smooth scrolling (which is then turned back on with $58, NTSC on, and the 3 lower bits set to high).

Luca: let me do some checking. I didn't write the original code, but I did notice that $ff1e was the horizontal register, not the vertical but it still seemed to work in PAL. Let's see what I can do with $ff1d instead.

Posted By

icbrkr
on 2014-10-29
19:52:43
 Re: general smooth scrolling questions

Okay, I got it to function the same way as before using $FF1D but it didn't solve the issue.

I do believe gerliczer has a point where it's setting PAL when doing the raster, but I don't see where I'm setting it in code.

How about this... can someone show me an example of a standard 1x1 char scroll? Once I get -that- working the way it should, I can worry about the rest.

Posted By

gerliczer
on 2014-10-30
06:12:59
 Re: general smooth scrolling questions

OK, let's have a bit more details:

Snippet two shows that $FF07 should have written in the high nybble $5.
Snippet one shows that $FF07 is filled from HorizPos.
Snippet three shows that HorizPos is filled with a value not having $5 in the high nybble, and I don't see, but I may be wrong, anything that would correct this difference.

Suggestion:
LDA HorizPos
ORA #$50
STA $FF07


Posted By

KiCHY
on 2014-10-30
06:44:28
 Re: general smooth scrolling questions

I prefer not to touch other bits only I need:
lda $ff07
and #$f8 ; Clear old value of horizontal position
ora HorizPos ; between 0-7 right?
sta $ff07

Setting PAL/NTSC bit when it's unnecessary leads to bad habit then later comes PAL/NTSC fix versions happy

Posted By

gerliczer
on 2014-11-01
05:44:35
 Re: general smooth scrolling questions

Depends on what are your priorities. If it is a quick hack, screw portability, then it is good as simple as it can be. If you want system friendly coding, then of course you should set your registers carefully.

Edit:

Hi icbrkr,

Any developments on smooth scrolling yet?

Posted By

icbrkr
on 2014-11-01
16:59:20
 Re: general smooth scrolling questions

Yup, this fixed it:

LDA HorizPos
ORA #$50
STA $FF07

I took out the setting of NTSC all together and let the system itself worry about it.

Thanks much guys.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon