TGB1718 Posted September 8, 2023 Share Posted September 8, 2023 Is it possible to enable horizontal scrolling and change the HSCROL register in a DLI, it appears you can change it once at the top of the display, but anywhere else produces a garbage screen below the DLI change. Here I'm changing the HSCROL register about 1/2 way down the screen and this is the result The program has not crashed, it exits normally on a key press, I'm using the VCOUNT register when it reaches 60, puts a value into the HSCROL register and that's it, DLI's are enabled on all lines, but this line is the only one that activates, this is GRAPHIC Mode 7 (Antic $E) I'm beginning to feel that what I'm trying to do is not possible. dlitest.mp4 Quote Link to comment Share on other sites More sharing options...
popmilo Posted September 8, 2023 Share Posted September 8, 2023 Yes it is possible. Do it right after wsync in previous line and you're safe. Check altirra debugger, step by step to see where the change happens. If you get stuck, just post xex file and someone will find your issue. Cheers! Vladimir Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 8, 2023 Author Share Posted September 8, 2023 8 minutes ago, popmilo said: Do it right after wsync in previous line and you're safe. Yes, I am doing it after a WSYNC, the display list is doing an LMS for each line which is 48 bytes wide with DLI and HSCROL enabled, the playfield is standard width A very simple DLI:- .proc DLI pha lda VCOUNT cmp #60 bne xit lda #6 sta WSYNC sta HSCROL xit pla rti .endp Quote Link to comment Share on other sites More sharing options...
Rybags Posted September 8, 2023 Share Posted September 8, 2023 How many DLIs do you have going? If it's in a known location then why worry about looking at VCOUNT? In wide mode there can be 48 bytes of DMA loss for screen, then you have another 3 for the DList and more again for screen refresh. Also the cycle losses can be skewed depending on the HSCROL value. Though your code there does look reasonably tight. But obviously something is amiss since you're getting corruption. Generally HScrol corruption is a result of the store occurring partway thruough a scanline, which you normally don't want to be doing. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 8, 2023 Author Share Posted September 8, 2023 14 minutes ago, Rybags said: How many DLIs do you have going? If it's in a known location then why worry about looking at VCOUNT? Every line has DLI enabled, but I only activate one DLI at line 60 that's why I used VCOUNT, my normal code doesn't use this, I did this just to try to debug/figure out what's going on, so literally I draw stuff on screen enable the DLI with the code shown and I get garbage below that line, doesn't seem to make sense. I expected just to see the lower 1/2 of the screen offset from the top. There's no VBI's yet, I disabled them to make sure there wasn't any conflict. Guess I'll have to dig a bit deeper to see what's going on. Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 8, 2023 Share Posted September 8, 2023 (edited) You should set the hscrol in vbi to the top half value as otherwise the 6 you are setting is just persisting to the next frame. [Edit] could he corruption could be as a result of crossing the 4k screen boundry? Typically that should resolve on the next lms though. Edited September 8, 2023 by Wrathchild 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 8, 2023 Author Share Posted September 8, 2023 7 minutes ago, Wrathchild said: could he corruption could be as a result of crossing the 4k screen boundry? no, I created a "createdl" procedure that makes sure the display list aligns correctly to ensure the 4K boundary is crossed safely. Without the DLI set, the screen looks correct and a small VBI routine can scroll the screen horizontally with no corruption. It only corrupts if I try any horizontal scrolling in a DLI. Quote Link to comment Share on other sites More sharing options...
thorfdbg Posted September 8, 2023 Share Posted September 8, 2023 Yes, of course it is possible to change HSCROLL with an DLI - you can even create "italics" fonts by adjusting it from line to line, thus "slanting" the text. From what I see in your video, it seems that you actually damage the display list. What you should not try is to adjust HSCROLL outside the horizontal blank, i.e. you need a STA WSYNC (or find some other way of delaying the write such that it happens outside the visible area). 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 8, 2023 Author Share Posted September 8, 2023 @thorfdbg thanks you, you gave me the clue as to what I was doing wrong, I was setting the HSCROL register to 0 outside of the DLI, but not inside a VBI, my code was just stuffing 0 into HSCROL while waiting for a key press. Pretty obvious really, but sometimes you just overlook something so simple. Fixed now as the screen shot shows, now I can get on with what I was trying to achieve Thanks to all who helped here 4 Quote Link to comment Share on other sites More sharing options...
phaeron Posted September 8, 2023 Share Posted September 8, 2023 WSYNC/horizontal blank isn't sufficient to avoid this problem. The specific requirement is that you can't safely change HSCROL until the playfield DMA clock has finished, and at wide fetch that extends into horizontal blank. You have to burn at least 7 cycles after STA WSYNC to be safe -- 1 for the extra cycle you may or may not get before RDY is pulled, and 6 to clear the farthest that the DMA clock can run. 2 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 8, 2023 Author Share Posted September 8, 2023 (edited) 1 hour ago, phaeron said: You have to burn at least 7 cycles after STA WSYNC to be safe -- 1 for the extra cycle you may or may not get before RDY is pulled, and 6 to clear the farthest that the DMA clock can run. @phaeron thank you I will take that into account if thing look a bit screwed up EDIT: Spot on, it looked a bit garbled, I added a few NOP's after the WSYNC and it now look really good. 🤩 Edited September 8, 2023 by TGB1718 3 Quote Link to comment Share on other sites More sharing options...
popmilo Posted September 11, 2023 Share Posted September 11, 2023 Solving such problem always feels nice Altirra debugger is your friend there... "ba w HSCROL" in console will make a breakpoint on any write of hscrol reg. You would see strange things happening right away. Problem is that it's easy to be clever after you solve bugs like these Good luck, wish you least amount of bugs possible in the future 2 Quote Link to comment Share on other sites More sharing options...
pirx Posted September 12, 2023 Share Posted September 12, 2023 On 9/8/2023 at 3:29 PM, phaeron said: (...) You have to burn at least 7 cycles after STA WSYNC to be safe (...) Oh boy, how many trials and errors when we were young and no phaeron to help. I never got the real understanding before, just moving bits and pieces until it somewhat worked 😮 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted September 12, 2023 Author Share Posted September 12, 2023 I know what you mean, I was looking at some old code I wrote back in the 80's, not DLI stuff, but there's a couple of NOP instructions and a comment, need a small delay, I think it was a hardware driver, so probably just a short wait or I would miss something Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.