I have seen many examples of assembler code to autodetect which version of the VDP an MSX is equipped with. But is it possible to also detect how much VRAM does it have?
Login or register to post comments
I have seen many examples of assembler code to autodetect which version of the VDP an MSX is equipped with. But is it possible to also detect how much VRAM does it have?
I think that is the same way like detecting the amount of RAM: WRITE -> READ and COMPARE
- Select a bank of VRAM with register 14
- Write in a direction of VRAM a value
- Read that direction and compare
- The same value?? -> select next bank of VRAM....
oh! ok, that actually makes sense. I just gave it a try, and assuming we have an MSX2, just doing this is enough to know if we have more than 16KB of VRAM:
xor a
ld hl,#0000
call NWRVRM
ld a,1
ld hl,#4000
call NWRVRM
ld hl,#0000
call NWRVRM
or a
jp z,morethan16kb
I'll play around with this tomorrow to see if I can find a way to do it without assuming we are on an MSX2 (since those BIOS calls are only available on MSX2...)
Do it direclty:
Taken from Grauws page:
;
;Set VDP port #98 to start writing at address AHL (17-bit)
;
SetVdp_Write: rlc h
rla
rlc h
rla
srl h
srl h
di
out (#99),a ;set bits 15-17
ld a,14+128
out (#99),a
ld a,l ;set bits 0-7
nop
out (#99),a
ld a,h ;set bits 8-14
or 64 ; + write access
ei
out (#99),a
ret
;
;Set VDP port #98 to start reading at address AHL (17-bit)
;
SetVdp_Read: rlc h
rla
rlc h
rla
srl h
srl h
di
out (#99),a ;set bits 15-17
ld a,14+128
out (#99),a
ld a,l ;set bits 0-7
nop
out (#99),a
ld a,h ;set bits 8-14
ei ; + read access
out (#99),a
ret
The bits 2 and 1 of the system variable "MODE" at 0FAFCh is used to indicate the amount of VRAM of the MSX. (00 for 16kB, 01 for 64kB, 10 for 128kB and 11 for 192Ko)
The bits 2 and 1 of the system variable "MODE" at 0FAFCh is used to indicate the amount of VRAM of the MSX. (00 for 16kB, 01 for 64kB, 10 for 128kB and 11 for 192Ko)
gdx!!! That's really an easier way!! LOL
Oh! even better, thanks guys! going to try this right now! 
edit: confirmed, just these three lines of code do the trick!! (thanks again!)
ld a,(MODE)
and #06
jp z,only16kb
santiontanon: a few very rare MSX2's only have 64kB VRAM. So take care of that, if you want
Don't you have an account yet? Become an MSX-friend and register an account!
