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
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 (http://www.commodore128.org/index.php?topic=1308.msg4548).
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
Thank you very much, it works correctly.
Miro
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.