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 > $d011 trickery – duplicated text lines
2011-04-29 21:39
Digger

Registered: Mar 2005
Posts: 447
$d011 trickery – duplicated text lines

Does any one know the $d011 trick to repeat the first char row? I am trying to cancel badlines on the 8th line of each charline (between cycles 54-57) but it doesn't work. The first line gets duplicated but only twice.
 
... 57 posts hidden. Click here to view all posts....
 
2021-11-21 01:49
Krill

Registered: Apr 2002
Posts: 3083
Quoting Rastah Bar
On rasterline $30 the last byte from each character in $0400 ... is visible, but in the colors from $dbe8 and so on. This caught my attention since I expected the screen ram and color ram memory addresses to match.
Both addresses should match, as they're coming from one and the same counter in VIC.

It seems like you're linecrunching right from the top of the screen. When you do that, there is no badline DMA in line $30 (otherwise you'd see the first, not the last, pixel row of the characters). Instead, whatever was put in the line buffer in the previous frame is displayed.

But colours and characters should come from matching addresses. Are you sure there is a mismatch?
2021-11-21 04:20
Martin Piper

Registered: Nov 2007
Posts: 739
Perhaps a picture would help? :)
2021-11-21 11:33
Rastah Bar
Account closed

Registered: Oct 2012
Posts: 336
Yes, there is a mismatch as you can see in the pictures in text mode and bitmap mode.

https://i.postimg.cc/qvLzbQ3D/text-mode.png
https://i.postimg.cc/WbsVWVwj/hires-bitmap-mode.png

The first character row $0400 ... $0427 is filled with inverse space.
Addresses $dbe8 .. $dbff contain 0,1,2,3,4,5,7,8,0,1, ...
Addresses $07e8 .. $07ff contain 0,0,ff,ff,ff,ff,0,0,0,0,ff,ff,ff,ff, ...
The first stripe in the right border is at line $2f
2021-11-21 11:43
Krill

Registered: Apr 2002
Posts: 3083
I'd find some actual code a lot more helpful, the pictures leave open too many questions. =)

And are you sure the top line in text mode is inverted spaces ($A0)? When and from where would they be fetched? Seems more likely to me that $d018 in the top line points to some memory that's not the character generator ROM, but just $ff somewhere in RAM, with not only the colours, but also the buffered characters matching those in the bottom character row.
2021-11-21 12:03
Rastah Bar
Account closed

Registered: Oct 2012
Posts: 336
Yes, I put in the inverted spaces manually in Vice monitor.
I also tried other character codes.

Btw, this mismatch occurs in Vice and micro64, Hoxs seems to have matching screen and color ram addresses. So this looks like an emulator bug.

Anyway, here is some code. You can play with the colors and character codes in the monitor.

/ZP-adresses
.const irqA = 2
.const irqX = 3
.const irqY = 4

//Variables
.var IrqLijn0 = $2f
.var IrqLijn1 = 255


*=$0801
// 10 SYS2064 
.byte    $0B, $08, $0A, $00, $9E, $32, $30, $36, $34, $00, $00, $00

*=$0810
//set up stable raster interrupt and put something on screen
        sei
        cld
        lda #0
        sta $d015
        
        ldy #00
l0:     ldx #39
        tya
m0:     sta $0400,x
        dex
        bpl m0
        clc
        lda m0+1
        adc #40
        sta m0+1
        bcc *+5
        inc m0+2
        iny
        cpy #25
        bcc l0

        lda #100
        sta $0404
        lda #1
        sta $d804

        lda #$7f
        sta $042b
        lda #3
        sta $d82b

        lda #86
        sta $042f
        lda #7
        sta $d82f

        ldx #7
        stx $dbeb
        ldx #5
        stx $dbec 
        ldx #13
        stx $dbed

        jsr setTimer  //stabilize raster

        lda #$7f   
        sta $dc0d  
        sta $dd0d  
        lda $dc0d  
        lda $dd0d  

        lda #$01  
        sta $d01a
        
        lda #IrqLijn0  
        sta $d012 
       
        lda #$1f     
        sta $d011 
        lda #<irq0
        sta $fffe
        lda #>irq0
        sta $ffff 
    
        lda #$35
        sta $01
        lda #$55
        sta $3fff

        lda #$01
        sta $d010

        inc $d019
        cli
        jmp *

//Raster irq every 4th line
irq0:
        sta irqA
        nop
        lda $dc06     
        eor #7
        sta *+4
        bpl *+2         //Note: make sure there is no page boundary crossing!
        lda #$a9
        lda #$a9
        lda $eaa5   
        
        
        stx irqX
        sty irqY
        ldx $d012

        inc $0200 //for delay purposes only

        inc $d020 //show current line in right border
        dec $d020
        
        inc $0200
//badline on next rasterline
        
        inx
        txa
        and #$07
        ora #$18		//$38
        sta $d011
        txa
        clc
        adc #$03		//irq every 4th line
        cmp #$f8
        bcs endscrn
        sta $d012
        inc $d019
        ldy irqY
        ldx irqX
        lda irqA
        rti

endscrn:
//open the border
        lda $d011
        and #$f7
        sta $d011
        
        bit $d011
        bpl *-3

        lda #$1f		//$3f
        sta $d011
        lda #IrqLijn0   //IrqLijn1
        sta $d012
        inc $d019
        ldy irqY
        ldx irqX
        lda irqA
        
        rti

//Stabilize raster
setTimer:


//Via badline detection with timer
        lax $dc04      
        sbx #51
        sta irqA
        cpx $dc04
        bne setTimer    //Note: make sure there is no page boundary crossings!
//wait till cycle 54 with setting $dc0f
        ldx #8
        dex
        bne *-1         
        bit $ea             
        lda #8
        sta $dc06
        stx $dc07
        lda #$11
        sta $dc0f     //This instruction should happen on cycle 54
        rts

2021-11-21 12:17
tlr

Registered: Sep 2003
Posts: 1807
Quoting Rastah Bar
Btw, this mismatch occurs in Vice and micro64, Hoxs seems to have matching screen and color ram addresses. So this looks like an emulator bug.

This may well be but needs to be compared to actual hw before investigating further.

EDIT: and make sure you use a recent x64sc.
2021-11-21 12:21
Krill

Registered: Apr 2002
Posts: 3083
Yeah, always check on realthing before even posting about unexpected behaviour. :)
2021-11-21 12:40
Rastah Bar
Account closed

Registered: Oct 2012
Posts: 336
I can't check on the real thing, unfortunately.
2021-11-21 14:21
Martin Piper

Registered: Nov 2007
Posts: 739
Using my C64C and Vice 3.1 rev 34062M

And this code which clears most of the memory (ClearMemStart) and $d800... to expected values:

;ZP-adresses
irqA = 2
irqX = 3
irqY = 4

;Variables
IrqLijn0 = $2f
IrqLijn1 = 255


*=$0801
; 10 SYS2064 
	!by    $0B, $08, $0A, $00, $9E, $32, $30, $36, $34, $00, $00, $00

*=$0810
;set up stable raster interrupt and put something on screen
        sei
		lda #%100000
		sta $01
		ldx #0
.clm1	stx ClearMemStart
	inx
	inc .clm1+1
	bne .clm1
	inc .clm1+2
	bne .clm1
	lda #%110111
	sta $01
	
        cld
        lda #0
        sta $d015
        
        ldy #00
l0:     ldx #39
        tya
m0:     sta $0400,x
m1:	sta $d800,x
        dex
        bpl m0
        clc
        lda m0+1
        adc #40
        sta m0+1
        bcc *+5
        inc m0+2

	clc
	lda m1+1
	adc #40
	sta m1+1
	bcc *+5
	inc m1+2

        iny
        cpy #25
        bcc l0

        lda #100
        sta $0404
        lda #1
        sta $d804

        lda #$7f
        sta $042b
        lda #3
        sta $d82b

        lda #86
        sta $042f
        lda #7
        sta $d82f

        ldx #7
        stx $dbeb
        ldx #5
        stx $dbec 
        ldx #13
        stx $dbed

        jsr setTimer  ;stabilize raster

        lda #$7f   
        sta $dc0d  
        sta $dd0d  
        lda $dc0d  
        lda $dd0d  

        lda #$01  
        sta $d01a
        
        lda #IrqLijn0  
        sta $d012 
       
        lda #$1f     
        sta $d011 
        lda #<irq0
        sta $fffe
        lda #>irq0
        sta $ffff 
    
        lda #$35
        sta $01
        lda #$55
        sta $3fff

        lda #$01
        sta $d010

        inc $d019
        cli
        jmp *

;Raster irq every 4th line
irq0:
        sta irqA
        nop
        lda $dc06     
        eor #7
        sta *+4
        bpl *+2         ;Note: make sure there is no page boundary crossing!
        lda #$a9
        lda #$a9
        lda $eaa5   
        
        
        stx irqX
        sty irqY
        ldx $d012

        inc $0200 ;for delay purposes only

        inc $d020 ;show current line in right border
        dec $d020
        
        inc $0200
;badline on next rasterline
        
        inx
        txa
        and #$07
        ora #$18		;$38
        sta $d011
        txa
        clc
        adc #$03		;irq every 4th line
        cmp #$f8
        bcs endscrn
        sta $d012
        inc $d019
        ldy irqY
        ldx irqX
        lda irqA
        rti

endscrn:
;open the border
        lda $d011
        and #$f7
        sta $d011
        
        bit $d011
        bpl *-3

        lda #$1f		;$3f
        sta $d011
        lda #IrqLijn0   ;IrqLijn1
        sta $d012
        inc $d019
        ldy irqY
        ldx irqX
        lda irqA
        
        rti

;Stabilize raster
setTimer:


;Via badline detection with timer
        lax $dc04      
        sbx #51
        sta irqA
        cpx $dc04
        bne setTimer    ;Note: make sure there is no page boundary crossings!
;wait till cycle 54 with setting $dc0f
        ldx #8
        dex
        bne *-1         
        bit $ea             
        lda #8
        sta $dc06
        stx $dc07
        lda #$11
        sta $dc0f     ;This instruction should happen on cycle 54
        rts


ClearMemStart



I get the following results, which roughly match between the real and emulator, with the exception of the bottom row:


https://drive.google.com/file/d/1VO8YEHkEySVaQ5p-vq3LuSFdcVVWeB..

https://drive.google.com/file/d/1V7T2JliDT3KXjbuOrNwJG9pWWgKsTS..

https://drive.google.com/file/d/1V5TBd_lPCWkyBlNxhXJdgwA1yxivwG..
2021-11-21 14:24
Martin Piper

Registered: Nov 2007
Posts: 739
PS. I'm not exactly sure why the C64C bottom row is showing different "T" chars with colours compared to the Vice emulator which shows the usual "black $FF char"?

PPS. I used: acme.exe --msvc -v3 --cpu 6510 -f cbm -o c:\temp\vicbug.prg c:\temp\vicbug.a
Yes, sorry, I use ACME :)
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 - Next
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
MP Software/Hokuto F..
Alakran_64
Exile/Anubis
Mythus/Delysid
Pixelnacho
rambo/Therapy/ Resou..
Guests online: 383
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Uncensored  (9.5)
9 Wonderland XIV  (9.5)
10 No Bounds  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Performers  (9.3)
5 Censor Design  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Acidchild  (9.7)
4 Cash  (9.6)
5 Violator  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.064 sec.