| |
Darksoft Account closed
Registered: Mar 2009 Posts: 3 |
Gfx Glitch problem
Hello everyone,
I'm trying to fix a code that divides the screen in two blocks and switches between two different char-sets and screen areas, as the raster moves.
The problem is that at the bottom of the first block, the last line is showing always glitches.
I believe it has something to do with the change between the two charsets beeing done not quick enough.
I attach the code so maybe someone can help out. Selected Vic-Bank is $4000-$7FFF.
Thanks in advance.
.C:124f A9 01 LDA #$01
.C:1251 2C 19 D0 BIT $D019
.C:1254 8D 19 D0 STA $D019
.C:1257 D0 06 BNE $125F
.C:1259 AD 0D DC LDA $DC0D
.C:125c 4C C2 12 JMP $12C2
.C:125f A5 34 LDA $34
.C:1261 18 CLC
.C:1262 69 01 ADC #$01
.C:1264 C9 03 CMP #$03
.C:1266 D0 02 BNE $126A
.C:1268 A9 00 LDA #$00
.C:126a 85 34 STA $34
.C:126c C9 01 CMP #$01
.C:126e F0 34 BEQ $12A4
.C:1270 90 0D BCC $127F
.C:1272 A9 D0 LDA #$D0
.C:1274 8D 16 D0 STA $D016
.C:1277 A9 FB LDA #$FB
.C:1279 8D 12 D0 STA $D012 SET RASTER VALUE FOR IRQ
.C:127c 4C D9 2B JMP $2BD9
.C:127f A9 02 LDA #$02
.C:1281 8D 18 D0 STA $D018 ( CHAR ROM=4800-4FFF & SCREEN MEMORY=4000-4400 )
.C:1284 A9 D0 LDA #$D0
.C:1286 05 4B ORA $4B
.C:1288 8D 16 D0 STA $D016
.C:128b A9 10 LDA #$10
.C:128d 05 4C ORA $4C
.C:128f 8D 11 D0 STA $D011
.C:1292 A9 B4 LDA #$B4
.C:1294 8D 12 D0 STA $D012 SET RASTER VALUE FOR IRQ
.C:1297 A9 07 LDA #$07
.C:1299 8D 22 D0 STA $D022
.C:129c A9 05 LDA #$05
.C:129e 8D 21 D0 STA $D021
.C:12a1 4C D1 28 JMP $28D1
.C:12a4 A9 1E LDA #$1E
.C:12a6 8D 18 D0 STA $D018 ( CHAR ROM=7800-7FFF & SCREEN MEMORY=4400-4800 )
.C:12a9 A9 D0 LDA #$D0
.C:12ab 8D 16 D0 STA $D016
.C:12ae A9 17 LDA #$17
.C:12b0 8D 11 D0 STA $D011
.C:12b3 A9 CC LDA #$CC
.C:12b5 8D 12 D0 STA $D012 SET RASTER VALUE FOR IRQ
.C:12b8 A9 02 LDA #$02
.C:12ba 8D 22 D0 STA $D022
.C:12bd A9 00 LDA #$00
.C:12bf 8D 21 D0 STA $D021
.C:12c2 A9 2F LDA #$2F
.C:12c4 85 00 STA $00
.C:12c6 A5 35 LDA $35
.C:12c8 85 01 STA $01
.C:12ca 68 PLA
.C:12cb A8 TAY
.C:12cc 68 PLA
.C:12cd AA TAX
.C:12ce 68 PLA
.C:12cf 40 RTI
|
|
| |
Monte Carlos
Registered: Jun 2004 Posts: 359 |
I see, that you did'nt switch off the system irq.
This disturbs everything, because the system irq is running at 60Hz and the raster irq is running at 50Hz. Sooner or later you get a race condition between the two irqs. Before starting the irq set $d01a to $81 and $dc0d to $7f. Then you don't need this sequence
.C:124f A9 01 LDA #$01
.C:1251 2C 19 D0 BIT $D019
.C:1254 8D 19 D0 STA $D019
.C:1257 D0 06 BNE $125F
.C:1259 AD 0D DC LDA $DC0D
.C:125c 4C C2 12 JMP $12C2
but only LSR $d019.
I remember a topic about proper irq initialization, maybe someone could post a link here. ;)
Starting an irq routine at an arbitrary memory location is not a good idea, because some opcodes need additional cycles, if they lay across a page boundary. Therefore make your irq routine start always at a multiple of $100.
If you see still glitches, than simply add or delete some commands, which waste some time. Examples: nop=2cyc.,
bit $0x = 3 cyc, lda $ffff = 4cyc, rol $0340 = 5 cyc., lda(0,x) = 6cyc.
|
| |
JSL
Registered: Aug 2003 Posts: 56 |
ask Roland Hermans, NEO, from Holland where i live.
greets,
Johan aka JSL
PS:
find him on CSDb ofcourse.
|
| |
Darksoft Account closed
Registered: Mar 2009 Posts: 3 |
Quote: I see, that you did'nt switch off the system irq.
This disturbs everything, because the system irq is running at 60Hz and the raster irq is running at 50Hz. Sooner or later you get a race condition between the two irqs. Before starting the irq set $d01a to $81 and $dc0d to $7f. Then you don't need this sequence
.C:124f A9 01 LDA #$01
.C:1251 2C 19 D0 BIT $D019
.C:1254 8D 19 D0 STA $D019
.C:1257 D0 06 BNE $125F
.C:1259 AD 0D DC LDA $DC0D
.C:125c 4C C2 12 JMP $12C2
but only LSR $d019.
I remember a topic about proper irq initialization, maybe someone could post a link here. ;)
Starting an irq routine at an arbitrary memory location is not a good idea, because some opcodes need additional cycles, if they lay across a page boundary. Therefore make your irq routine start always at a multiple of $100.
If you see still glitches, than simply add or delete some commands, which waste some time. Examples: nop=2cyc.,
bit $0x = 3 cyc, lda $ffff = 4cyc, rol $0340 = 5 cyc., lda(0,x) = 6cyc.
Thanks for quick reply.
The beginning of the IRQ is set at 1233, which in this case seems not to be affected by a page change.
.C:1233 48 PHA
.C:1234 8A TXA
.C:1235 48 PHA
.C:1236 98 TYA
.C:1237 48 PHA
.C:1238 BA TSX
.C:1239 4C 48 12 JMP $1248
.C:123c A9 2F LDA #$2F
.C:123e 85 00 STA $00
.C:1240 86 01 STX $01
.C:1242 60 RTS
.C:1243 A2 35 LDX #$35
.C:1245 4C 3C 12 JMP $123C
.C:1248 A5 01 LDA $01
.C:124a 85 35 STA $35
.C:124c 20 43 12 JSR $1243
ETC (see first post)
I changed the code outside the IRQ and I introduced the change Monte Carlos proposed, but no change...
.C:12d0 A9 81 LDA #$81
.C:12d2 8D 1A D0 STA $D01A
.C:12d5 A9 7F LDA #$7F
.C:12d7 8D 0D DC STA $DC0D
Also adding delays didn't help. But I noticed that the longer the delay, the higher number of corrupted lines shown at the bottom.
Any comment will be appretiated.
Thanks in advance.
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Quote: Thanks for quick reply.
The beginning of the IRQ is set at 1233, which in this case seems not to be affected by a page change.
.C:1233 48 PHA
.C:1234 8A TXA
.C:1235 48 PHA
.C:1236 98 TYA
.C:1237 48 PHA
.C:1238 BA TSX
.C:1239 4C 48 12 JMP $1248
.C:123c A9 2F LDA #$2F
.C:123e 85 00 STA $00
.C:1240 86 01 STX $01
.C:1242 60 RTS
.C:1243 A2 35 LDX #$35
.C:1245 4C 3C 12 JMP $123C
.C:1248 A5 01 LDA $01
.C:124a 85 35 STA $35
.C:124c 20 43 12 JSR $1243
ETC (see first post)
I changed the code outside the IRQ and I introduced the change Monte Carlos proposed, but no change...
.C:12d0 A9 81 LDA #$81
.C:12d2 8D 1A D0 STA $D01A
.C:12d5 A9 7F LDA #$7F
.C:12d7 8D 0D DC STA $DC0D
Also adding delays didn't help. But I noticed that the longer the delay, the higher number of corrupted lines shown at the bottom.
Any comment will be appretiated.
Thanks in advance.
o_O spaghetti code. you should eliminate all the unnecessary jmps, and put the randomly scattered code fragments which jumps into eachother into one segment, instead of the random placement and jmps...
also, you dont need to store the stack pointer inside an irq (unless you really do something weird with it)
if adding delays doesnt help, then move the irq on rasterline higher, and then try to add/remove delays. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
"Starting an irq routine at an arbitrary memory location is not a good idea, because some opcodes need additional cycles, if they lay across a page boundary. Therefore make your irq routine start always at a multiple of $100."
this is only important when you need cycle exact timing, at this code this is not the case. its totally unimportant. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
http://codebase64.org/doku.php?id=base:introduction_to_raster_i..
|
| |
Darksoft Account closed
Registered: Mar 2009 Posts: 3 |
Thank you Oswald,
If I understood right, you mean changing the rasterline at $1292 from $b4, to for instance $b3 and then add some delays?
I tried that but still the same.
thanks anyway.
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
the first thing i would suggest is using some sort of stable raster irq (look at codebase). its probably not really needed, but it will make the "put irq one line before and then add delay until it works"-thing a lot easier and more predictable. |
| |
SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
line 1:
poke d018,xx
line 2:
ldx #4 (pause)
.dex
bne .
poke d018,yy
to get no flicker, move line 2 maybe 1 line down, and adjust the ldx |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Quote: Thank you Oswald,
If I understood right, you mean changing the rasterline at $1292 from $b4, to for instance $b3 and then add some delays?
I tried that but still the same.
thanks anyway.
then add an inc $d021 dec $d021 (change it to d020 if you see nothing you might be on the borders) right before/after the d018 change. then you will visually see whats the problem with your timing.
stable raster what groepaz suggests is definitly not needed. everyone comes up with cycle exact approaches when this stuff works with bare raster irqs without any cycle exact stuff techniques. even on badlines.
maybe the problem is that you update $d011 aswell ? that can lead to ugly sideeffects, and you dont need it, if you only hcnage charsets.
anyway&again this is possible without any fancy timing techniques, all you need is finding the correct rasterline and adding/removing enough nops.
please for god's sake also use chained irqs. you're not restricted to use only one irq routine and ugly complicated mechanisms to decide what to do.
irq1 lda #xx sta $d018
change irq vector&d012 place to irq2
rti
irq2 lda #yy sta $d018
change irq vector&d012 place to irq1
rti |
... 7 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 - Next |