VDC on real C128 and on VICE

Started by MIRKOSOFT, June 06, 2010, 03:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!

I was programming routine which saves VDC screen and attributes to unused area in VDC ($1000 - $1ffff) and when I need loads these data back to screen.
I tried it in VICE and everything was ok, but when I run it on real C128 it makes some bugs and any chars and attributes were not correctly loaded back.

Where can be problem?

Here's code:


vdc_save:
ldx #$00
ldy #$10
stx x_w
sty y_w
ldx #$00
ldy #$00
citaj: stx x_r
sty y_r
stx lobyte
sty hibyte
jsr vdc_prepare
jsr vdc_read
sta temp
ldx x_w
stx lobyte
ldy y_w
sty hibyte
jsr vdc_prepare
lda temp
jsr vdc_write
inx
stx x_r
stx x_w
ldy y_r
cpx #$00
bne citaj
ldy y_w
iny
sty y_w
tya
and #$0f
tay
sty y_r
cpy #$00
beq done
jmp citaj
done: rts

vdc_load:
ldx #$00
ldy #$00
stx x_w
sty y_w
ldx #$00
ldy #$10
citaj1: stx x_r
sty y_r
stx lobyte
sty hibyte
jsr vdc_prepare
jsr vdc_read
sta temp
ldx x_w
stx lobyte
ldy y_w
sty hibyte
jsr vdc_prepare
lda temp
jsr vdc_write
inx
stx x_r
stx x_w
ldy y_r
cpx #$00
bne citaj1
ldy y_r
iny
sty y_r
tya
and #$0f
tay
sty y_w
cpy #$00
beq done1
ldy y_r
jmp citaj1
done1: rts


Thanks for every help, many thanks.

Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

Payton Byrd

I had to do this for CBM Command.  You should look at the source code for it:


http://cbmcommand.codeplex.com/SourceControl/changeset/view/47031#829975

Payton Byrd
---------------------------------------------------
Flat 128 w/JD, uIEC/SD, uIEC-CF/IDE,
1541 Ultimate, 1571 w/JD, 1581 w/JD,
VDC-SVideo, Visio 19" HDTV

BigDumbDinosaur

Quote from: Payton Byrd on June 06, 2010, 08:02 AM
I had to do this for CBM Command.  You should look at the source code for it:


http://cbmcommand.codeplex.com/SourceControl/changeset/view/47031#829975
You should consider using the 128's screen kernel ROM routines to access the VDC instead of using direct reads and writes to the VDC's registers.  If your software were to be run on a 128 running either Clock-Calendar 128 or the 80 Column Display Manager, you'd end up with random artifacts on the screen due to register conflicts.  CC128 and 80CDM avoid this sort of thing by sniffing the stack and deferring VDC access if a screen kernel routine that "touches" the VDC is in progress.  If a user-written program bypasses the screen kernel and directly accesses the VDC, it'll only be a matter of time before a conflict will occur, resulting in baby barf for a display.
x86?  We ain't got no x86.  We don't need no stinking x86!

Payton Byrd

There aren't any kernel routines to save the screen.  There is no choice but to follow the procedure I used in CBM-Command.
Payton Byrd
---------------------------------------------------
Flat 128 w/JD, uIEC/SD, uIEC-CF/IDE,
1541 Ultimate, 1571 w/JD, 1581 w/JD,
VDC-SVideo, Visio 19" HDTV

Hydrophilic

I think you failed to provide enough information to solve your problem.  For example, your code references "lobyte", "hibyte", and "vdc_prepare"; but none of these are defined in the code you provided!  Your code also references "vdc_read" and "vdc_write", but I assume they are the same (or equivalant) to those in the KERNAL/EDITOR ROM.

If Payton Byrd's code doesn't help you, try posting a more complete program.
I'm kupo for kupo nuts!

BigDumbDinosaur

Quote from: Payton Byrd on June 23, 2010, 11:31 AM
There aren't any kernel routines to save the screen.  There is no choice but to follow the procedure I used in CBM-Command.
You misunderstood me.  Of course, the screen kernel has no routines to save/restore portions of VRAM.  What I was saying is you are including primitives in your code that access the VDC hardware without regard for other activity that may be going on in the C-128.  Instead, take a look at the following subroutines in the screen kernel:

WRITE80   $CDCA    write to VRAM
WRITEREG  $CDCC    write to VDC register
READ80    $CDD8    read from VRAM
READREG   $CDDA    read from VDC register


Mapping the Commodore 128 gives a complete description on how to use these ROM routines to directly control the VDC.

You might also want to consider using the 80 Column Display Manager, which does a lot of the grunt work for you in buffering and restoring screens.  Why reinvent the wheel?  80CDM does all of that work plus offers some extras you may find useful.
x86?  We ain't got no x86.  We don't need no stinking x86!

Payton Byrd

Quote from: BigDumbDinosaur on June 25, 2010, 02:58 AM
Quote from: Payton Byrd on June 23, 2010, 11:31 AM
There aren't any kernel routines to save the screen.  There is no choice but to follow the procedure I used in CBM-Command.
You misunderstood me.  Of course, the screen kernel has no routines to save/restore portions of VRAM.  What I was saying is you are including primitives in your code that access the VDC hardware without regard for other activity that may be going on in the C-128.  Instead, take a look at the following subroutines in the screen kernel:

WRITE80   $CDCA    write to VRAM
WRITEREG  $CDCC    write to VDC register
READ80    $CDD8    read from VRAM
READREG   $CDDA    read from VDC register


Mapping the Commodore 128 gives a complete description on how to use these ROM routines to directly control the VDC.


Noted for future reference.


Quote from: BigDumbDinosaur on June 25, 2010, 02:58 AM
You might also want to consider using the 80 Column Display Manager, which does a lot of the grunt work for you in buffering and restoring screens.  Why reinvent the wheel?  80CDM does all of that work plus offers some extras you may find useful.


The reason I'm not using 80 column display manager, or any other 3rd party display manager for either 64 or 128 versions of CBM-Command is because there is a VERY STRONG NEED to standardize screen access to CONIO.H which allows the code to be shared across the two platforms without a billion #ifdef statements all over the place.
Payton Byrd
---------------------------------------------------
Flat 128 w/JD, uIEC/SD, uIEC-CF/IDE,
1541 Ultimate, 1571 w/JD, 1581 w/JD,
VDC-SVideo, Visio 19" HDTV