| |
Starfox
Registered: Jul 2014 Posts: 31 |
Can anyone debug this terrible FLD code that isn't working
Was fiddling with FLD, at work of course, but seems I've made a mistake somewhere. The FLD just flickers all over the screen.
Anyone? :)
Sorry for TERRIBLE formatting when posting the code here.
BasicUpstart2(main)
.var line = 81
main: sei // disable maskable interrupts
lda #$7f // disable timer interrupts
sta $dc0d
sta $dd0d
lda $dc0d // disable pending timer interrupts
lda $dd0d
lda #1
sta $d01a // tell VICII to generate a raster interrupt
lda #line // rasterline to generate the interrupt on
sta $d012
lda #$1b // raster lines > 256, needs bit #7 of $d011 to be set
sta $d011 // as it is the 9th bit of $d012
lda #$35 // RAM everywhere but SID/VICII etc. ($d000-dfff)
sta $01
lda #<irq1
ldx #>irq1
sta $fffe
stx $ffff
cli // allow maskable interrupts again
jmp *
irq1: sta atemp+1 // preserve registers
stx xtemp+1
sty ytemp+1
lda #<irq2
ldx #>irq2
sta $fffe
stx $ffff
inc $d012 // we want interrupt on next raster line
lda #1
sta $d019
tsx
cli
nop // wait for interrupt to happen
nop
nop
nop
nop
nop
nop
nop
irq2: txs
ldx #8 // tricks
dex
bne *-1
bit $00
lda $d012
cmp $d012
beq *+2
// stable raster now
lda #7
sta $d020
// FLD
ldx #10
FLD:
lda $d012
cmp $d012
beq *-3
clc // one line of FLD. *Snort* Ahh!!!
lda $d011
adc #1
and #7
ora #$18
sta $d011
dex
bne FLD
// effect over
lda #14
sta $d020
lda #<irq1
ldx #>irq1
sta $fffe
stx $ffff
lda #line
sta $d012
lda #1
sta $d019
atemp: lda #00
xtemp: ldx #00
ytemp: ldy #00
rti |
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11100 |
This should be trivial :) Hint:
In the FLD loop remove the cmp $d012 beq *-3. Don't add one to the value from $d011, but use $d012 instead :) Now after sta $d011 put a sta $d021. Now you see the color changes once per rasterline. Next add cycles to the loop until the point where the color changes are exactly in the same cycle each line. Now if it isnt already working, add or remove some cycles before the FLD loop. |
| |
TheRyk
Registered: Mar 2009 Posts: 2053 |
Quoting Starfox
Sorry for TERRIBLE formatting when posting the code here.
Please use BBCode opensquarebracketCODEclosesquarebracket then your code and close it with the same tag adding a slash before the "[" |
| |
Starfox
Registered: Jul 2014 Posts: 31 |
Quote: This should be trivial :) Hint:
In the FLD loop remove the cmp $d012 beq *-3. Don't add one to the value from $d011, but use $d012 instead :) Now after sta $d011 put a sta $d021. Now you see the color changes once per rasterline. Next add cycles to the loop until the point where the color changes are exactly in the same cycle each line. Now if it isnt already working, add or remove some cycles before the FLD loop.
Ahh, thanks! I knew it was something simple I had missed 👍😎 |
| |
Starfox
Registered: Jul 2014 Posts: 31 |
Quoting StarfoxWas fiddling with FLD, at work of course, but seems I've made a mistake somewhere. The FLD just flickers all over the screen.
Anyone? :)
Sorry for TERRIBLE formatting when posting the code here.
BasicUpstart2(main)
.var line = 81
main: sei // disable maskable interrupts
lda #$7f // disable timer interrupts
sta $dc0d
sta $dd0d
lda $dc0d // disable pending timer interrupts
lda $dd0d
lda #1
sta $d01a // tell VICII to generate a raster interrupt
lda #line // rasterline to generate the interrupt on
sta $d012
lda #$1b // raster lines > 256, needs bit #7 of $d011 to be set
sta $d011 // as it is the 9th bit of $d012
lda #$35 // RAM everywhere but SID/VICII etc. ($d000-dfff)
sta $01
lda #<irq1
ldx #>irq1
sta $fffe
stx $ffff
cli // allow maskable interrupts again
jmp *
irq1: sta atemp+1 // preserve registers
stx xtemp+1
sty ytemp+1
lda #<irq2
ldx #>irq2
sta $fffe
stx $ffff
inc $d012 // we want interrupt on next raster line
lda #1
sta $d019
tsx
cli
nop // wait for interrupt to happen
nop
nop
nop
nop
nop
nop
nop
irq2: txs
ldx #8 // tricks
dex
bne *-1
bit $00
lda $d012
cmp $d012
beq *+2
// stable raster now
lda #7
sta $d020
// FLD
ldx #10
FLD:
lda $d012
cmp $d012
beq *-3
clc // one line of FLD. *Snort* Ahh!!!
lda $d011
adc #1
and #7
ora #$18
sta $d011
dex
bne FLD
// effect over
lda #14
sta $d020
lda #<irq1
ldx #>irq1
sta $fffe
stx $ffff
lda #line
sta $d012
lda #1
sta $d019
atemp: lda #00
xtemp: ldx #00
ytemp: ldy #00/
rti
I must be getting too old, lol. I tried doing what you said, but I'm not sure I did it correct, as it's still bugging out. But it might have been Malwarebytes. I just got a notification that x64sc was ransomware lol.
EDIT: I think this is what you meant, it doesn't bug out anymore:
FLD:
lda $d012
//cmp $d012
//beq *-3
//clc // one line of FLD. *Snort* Ahh!!!
//lda $d011
//adc #1
and #7
ora #$18
sta $d011
sta $d021
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
dex
bne FLD
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11100 |
yes. remember what you want to achive - the lower 3 bits of $d012 should never match the lower 3 bits of $d011 (which is the badline condition). so load $d012, modify it (add 1) and write it to $d011 (it can work even when not adding one, that means the timing happens to be so when you write $d011, you are already one rasterline ahead) |
| |
Starfox
Registered: Jul 2014 Posts: 31 |
Quote: yes. remember what you want to achive - the lower 3 bits of $d012 should never match the lower 3 bits of $d011 (which is the badline condition). so load $d012, modify it (add 1) and write it to $d011 (it can work even when not adding one, that means the timing happens to be so when you write $d011, you are already one rasterline ahead)
Indeed! And thanks for the explanation! 👍 |