Can be detected VDC-RAM size in C64 mode?

Started by MIRKOSOFT, October 13, 2009, 06:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!

I have simple Q 'cause I want to use VDC-RAM as buffer in  program for C64 mode, so:

Can I detect size of VDC-RAM in C64 mode?

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

You can detect VDC RAM size in 64 mode much like 128 mode, except you don't have the Editor ROM to help you out.  I wrote a short test program for everyone that runs in 64 mode.

To use just:

LOAD"64VDCTEST.PRG",8,1
NEW:REM make BASIC happy
SYS49152
?PEEK(49222)


If BASIC prints zero (0) then you have 64K RAM.  If it prints anything else (probably 255) then you have 16K RAM.  This program leaves the VDC configured for 64K RAM so you should change the RAM setting back to 16K if you don't get a zero.

This is based on some experiments I did a while back.  See this thread.

Here is the "source" (I did it in the C128 MONITOR so this is all you get)

;set VDC to 64K mode
0C000  A2 1C    LDX #$1C  ;charset / RAM register
0C002  20 90 C0 JSR $C090 ;read register
0C005  09 10    ORA #$10  ;assume 64K size
0C007  20 82 C0 JSR $C082 ;write register
;write 0 to address $0000
0C00A  A2 12    LDX #$12  ;RAM address hi register
0C00C  A9 00    LDA #$00  ;value/address
0C00E  20 82 C0 JSR $C082 ;write register hi
0C011  E8       INX
0C012  20 82 C0 JSR $C082 ;write register lo
0C015  20 80 C0 JSR $C080 ;write zero into RAM
;write $FF to address $8000
0C018  A2 12    LDX #$12  ;RAM address hi register
0C01A  A9 80    LDA #$80  ;address hi
0C01C  20 82 C0 JSR $C082 ;write register hi
0C01F  E8       INX
0C020  A9 00    LDA #$00  ;address low
0C022  20 82 C0 JSR $C082 ;write register lo
0C025  A9 FF    LDA #$FF  ;value
0C027  20 80 C0 JSR $C080 ;write $FF into RAM
;get back RAM from $0000
0C02A  A2 12    LDX #$12 ;RAM register hi address
0C02C  A9 00    LDA #$00 ;address
0C02E  20 82 C0 JSR $C082 ;write register lo
0C031  E8       INX
0C032  20 82 C0 JSR $C082 ;write register hi
0C035  20 8E C0 JSR $C08E ;read RAM at $0000
0C038  8D 46 C0 STA $C046 ;save in +49222
0C03B  60       RTS
;empty space here...
;VDC write routines taken from C128 Editor ROM
0C080  A2 1F    LDX #$1F
0C082  8E 00 D6 STX $D600
0C085  2C 00 D6 BIT $D600
0C088  10 FB    BPL $C085
0C08A  8D 01 D6 STA $D601
0C08D  60       RTS
;VDC read routines
0C08E  A2 1F    LDX #$1F
0C090  8E 00 D6 STX $D600
0C093  2C 00 D6 BIT $D600
0C096  10 FB    BPL $C093
0C098  AD 01 D6 LDA $D601
0C09B  60       RTS


I'm kupo for kupo nuts!

MIRKOSOFT

Thank you very much, it works correctly.

Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

BigDumbDinosaur

You guys are reinventing the wheel.  I posted the source code to a VRAM sizing program that requires minimal editing to work on the 64.
x86?  We ain't got no x86.  We don't need no stinking x86!