| |
Trash
Registered: Jan 2002 Posts: 122 |
Why does this work and not that?
I have been playing around with this for a while and I cant understand why one configuration of the code removes the lower and upper border while the other one does not, can anyone explain this?
Uncomment the nops and comment the marked rows to se the difference:
; 64tass.exe %f -o %f.prg
rasterline .macro
lda #i
sta $d020
nop
nop
bit $ea
lda #\1
sta \2, x
lda $d012
sta $9000
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bit $ea
.endm
* = $0801
.byte $0b,$08, $d8, $07, $9e, $32, $30,$36, $34, $00, $00, $00, $00, $00, $00 ; 2008 SYS 2064 (G $0810)
;------------------------
RasterRow = $16
;------------------------
* = $0810
sei
lda #$35
sta $01
lda #$7f
sta $dc0d
lda $dc0d
lda #$01
sta $d01a
sta $d019
lda #<unstableraster
sta $fffe
lda #>unstableraster
sta $ffff
lda #RasterRow
sta $d012
lda #$1b
sta $d011
lda #$ff
cmp $d012
bne * - 3
cli
jmp *
;------------------------
unstableraster
lda #1 ; 2 2
sta $d019 ; 4 6
lda #RasterRow + 1 ; 2 8
sta $d012 ; 4 12
lda #<stableirq ; 2 14
sta $fffe ; 4 18
lda #>stableirq ; 2 20
sta $ffff ; 4 24
cli ; 2 26
-
.rept 19
nop ;38 64
.next
jmp -
;------------------------
stableirq
lda #1 ; 2 2
sta $d019 ; 4 6
lda #<unstableraster ; 2 8
sta $fffe ; 4 12
lda #>unstableraster ; 2 14
sta $ffff ; 4 18
lda #RasterRow ; 2 20
sta $d012 ; 4 24
.rept 11
nop ;22 46
.next
lda $d012 ; 4 50
cmp $d012 ; 4 54
.page
beq + ; 2 / 3 56 / 57
+ nop ; Make sure no pageboundaries are crossed here
.endp
;------------------------
; Irq is stable here
;------------------------
ldx #$0 ; 16
.for i = 0, i < 240, i = i + 1
.if i = $e0
lda #i
sta $d020
- lda $d012 ; Comment this out
cmp #248 ; Comment this out
bne * - 5 ; Comment this out, total of eight cycles
; nop ; Four nops = 8 cycles
; nop ; Why wont this work?
; nop
; nop
nop
nop
bit $ea
lda #16
sta $d011, x
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bit $ea
.else
#rasterline i, $d021
.fi
.next
lda #$08
sta $d011
lda #0
sta $d020
;------------------------
rti
;------------------------
|
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
just a shoot in the dark without looking at it too much: i see you are using a lot of macro stuff and then there are branches too.... make sure none of these branches crosses a page boundary, which will make it take 1 more cycle, and lead into "interisting" bugs, such as code changing behavior when you remove or add something :) (i usually make myself a macro for those branches, which then gives a warning when it crosses a page boundary) |
| |
Style
Registered: Jun 2004 Posts: 498 |
good call Id reckon. |
| |
Trash
Registered: Jan 2002 Posts: 122 |
Since the code has four rasterlines to play with to acieve the correct timing after:
- lda $d012 ; Comment this out
cmp #248 ; Comment this out
bne * - 5 ; Comment this out, total of eight cycles
I dont see how a missed .page can fix the error. So in plain english, that is not the problem here, the resulting error is the problem and nothing else. |
| |
WVL
Registered: Mar 2002 Posts: 902 |
Quote: Since the code has four rasterlines to play with to acieve the correct timing after:
- lda $d012 ; Comment this out
cmp #248 ; Comment this out
bne * - 5 ; Comment this out, total of eight cycles
I dont see how a missed .page can fix the error. So in plain english, that is not the problem here, the resulting error is the problem and nothing else.
How does that only take 8 cycles? :)
It's looping.. |
| |
Trash
Registered: Jan 2002 Posts: 122 |
Quote: How does that only take 8 cycles? :)
It's looping..
Because the lda $d012 occurs on rasterrow 248 so it will never loop, compile the code and check it out yourself the beviour is really strange.
|
| |
WVL
Registered: Mar 2002 Posts: 902 |
Quote: Because the lda $d012 occurs on rasterrow 248 so it will never loop, compile the code and check it out yourself the beviour is really strange.
lol, quickly removed my dumb stuff :D
|
| |
Trash
Registered: Jan 2002 Posts: 122 |
I've figured it out, finally!
The problem is that the first time the code runs without the $d012-stuff it gets badlines and comes below the area where I can make the $d011-trick and after that the screen stays turned off.. Simple as that! |