VDC programming - differences btw VICE and real machine

Started by MIRKOSOFT, January 18, 2011, 12:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!


I have big problem...


As everybody knows simple programming of VDC is:



BANK15
SYS DEC("CDCC"), value, register
or
BANK15
SYS 52684, value, register


where register is the number (0-36) of the internal VDC register
you wish to access, and value is the value (0-255) you
wish to place in that register.


To read the contents of an internal VDC register from
BASIC, use a statement of the form:


BANK15
SYS DEC("CDDA"),, register : RREG A
or
BANK15
SYS 52698,, register : RREG A


but I'm using my own routines to read/write to memory


.var vdcstatus = $d600
.var vdc_rw = $d601:



vdc_prepare:
   lda #$12
   sta vdcstatus
   lda hibyte
   sta vdc_rw
   lda #$13
   sta vdcstatus
   lda lobyte
   sta vdc_rw
   lda #$1f
   sta vdcstatus
   rts


vdc_write:   
notyet:   
   bit vdcstatus
   bpl notyet
   sta vdc_rw   // writting to VDC
   rts


vdc_read:   
notyet1:
   bit vdcstatus
   bpl notyet1
   lda vdc_rw   // reading from VDC
   rts


So, at first:


- when I'm using my own routines to R/W, all works correctly in VICE.
- if I use the same routines, it works not on real machine


- so, I tried to use simple method by $CDCC & $CDDA
- this works not in VICE and also not on real machine....


Where I'm doing mistake????


Thanks for every help.


Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

The code you posted looks okay to me.  Maybe it is something wrong with code that calls those routines.  It's been a while since I wrote BattleBlox, but that looks very similar to the code I used; it works fine in VICE and NTSC machine; no complaints from PAL users.
I'm kupo for kupo nuts!

MIRKOSOFT

Hi Robert!


So, if it looks correctly, why works it only at VICE?


I wrote lot of code for maybe known ACE128 OS, but first time tried to run it on real machine, and main problem is that ACE128 OS will work in VDC mode...


Here's example for copying charset from RAM $2000 to VDC RAM at $2000:




vdc_prepare:
lda #$12
sta vdcstatus
lda hibyte
sta vdc_rw
lda #$13
sta vdcstatus
lda lobyte
sta vdc_rw
lda #$1f
sta vdcstatus
rts


vdc_write:
notyet:
bit vdcstatus
bpl notyet
sta vdc_rw // writting to VDC
rts


vdc_read:
notyet1:
bit vdcstatus
bpl notyet1
lda vdc_rw // reading from VDC
rts

lobyte:
.byte 0


hibyte:
.byte 0



copy: lda #$00
ldx #$20
sta $fb
stx $fc
lda #$00
sta lobyte
lda #$20
sta hibyte
jsr vdc_prepare
ldy #00
xvdc: ldx #00
wvdc: lda ($fb),y
jsr vdc_write
iny
inx
cpx #08
bne wvdc
lda #$00
jsr vdc_write
jsr vdc_write
jsr vdc_write
jsr vdc_write
jsr vdc_write
jsr vdc_write
jsr vdc_write
jsr vdc_write
cpy #00
bne xvdc
inc $fc
lda $fc
cmp #$28
bne xvdc
rts



Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

It looks simple enough (no obvious error).  I don't have a compiler installed on this machine, so I'll get back to you. 
I'm kupo for kupo nuts!

MIRKOSOFT

for example source code & PRG executable SYS 10752
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

I still haven't got a chance to assemble and test your code.  I was working again on my taxes today.  If I were smart, I would buy some accounting software like QuickBooks.  But instead, I have to write my own database application.  Call me a compulsive programmer, I don't care  ::)

In case you don't know, one major problem with VICE is it does not handle VDC to VRAM address translation correctly.  Here you can read quite a technical discussion about it.  Anyway, you should check to be sure you set the VDC to the correct RAM setting before doing anything to VRAM.  This is bit 4 of internal register $1c, and should be 0 for 16 kiByte or 1 for 64 kiByte of VRAM.

To summarize the above-mentioned thread, VICE will work no matter what VRAM size it uses.  But on a real C128, if register $1c bit 4 does not match the VRAM size, then data will get scrambled.

Also, I just noticed that other bits of register $1c control the location of the character set.  Because this is what you are trying to change, it is very likely the problem.

Good luck!
I'm kupo for kupo nuts!

MIRKOSOFT

Hi Robert!


I have no problem to get size of VDC RAM. In my case it is 64kB.
All registers are set like they have.


Only one thing always makes mistake: COPYING TO VDC RAM.


Please, can you give me any suggestion to solve this?


Many many thanks.


Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

Well I tested the program you posted and it works okay in VICE and on my flat C128 (NTSC, 16 ki VRAM). 

Off topic
Because your program is for the 80-column, it made me finally get around to re-wiring my S-Video adapter... so thanks!  :)   Unfortunately, I completely lost dark gray... strange because it was working before (I have screen shots to prove it). Normally I would suspect my wiring, but the components are soldered and all the other colors are working... hmmm...

On topic
The problem is somewhere else.  Double check to make sure you set bit 4 to "1" in register $1c because you have 64 ki VRAM.

From my personal ROM (original buggy 1985 version), and the international version supplied with VICE (1986 version), it seems the KERNAL initializes register $1c with $20.  (This should be okay for addresses less than $4000 in VRAM.)  But if you have 64 ki VRAM, it should really be set to $30.  This error normally won't be obvious until you access VRAM > $4000 on a real C128.  The error will never appear in VICE until it implements correct VDC to VRAM address translation.

Finally, the program you listed was for uploading data into VDC RAM.  If you have trouble copying VRAM, (using VDC copy operation), then you should start another thread.  These are two completely different issues.
I'm kupo for kupo nuts!

MIRKOSOFT

Hi Robert!


I found solution by always writting number of register...


Now it works...


Many many thanks for your good work!


Cheers,


Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

I am glad you solved the problem, but I don't understand the solution.  Was the problem register $1c, or was the problem vdc_write ?

I think maybe you mean change like this ...

vdc_write:
pha
lda #$1f
sta vdcstatus
pla
notyet:
bit vdcstatus
bpl notyet
sta vdc_rw // writting to VDC
rts


Or maybe something different?  It would be nice to know for sure.  Thanks.
I'm kupo for kupo nuts!

MIRKOSOFT

Hi Robert!


I did alternative like you wrote, only one difference: I didn't used PHA & PLA, I used X-register...


Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk