Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Why does this work and not that?
2008-06-24 20:35
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
;------------------------
2008-06-24 20:41
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)
2008-06-25 10:56
Style

Registered: Jun 2004
Posts: 498
good call Id reckon.
2008-06-25 17:57
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.
2008-06-26 09:32
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..
2008-06-26 10:17
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.
2008-06-26 13:47
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

2008-06-26 16:15
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!
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Mike
iAN CooG/HVSC
MCM/ONSLAUGHT
Dr.Science/Atlantis
LKP/CFN
Elder0010/G★P
zscs
Youth
TheRyk/MYD!
Laddh
Holy Moses/Role
Guests online: 108
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.045 sec.