10 clear200,&hd000:definta-z:b=&hd000:screen0:width37:color15,4,4:dimt(20):goto30'ident.bas version 1 feb 2009
20 fori=bto(b+l):reada$:pokei,val("&h"+a$):next:defusr0=b:b=&hd000:return'read data
21 a$=inkey$:ifa$="y"ora$="Y"thenc=1:returnelseifa$="n"ora$="N"thenc=0:returnelsegoto21'check for yes/no
22 'automatic tests
29 't(10): psg pins 6/7 quirk: C=yes, F=NO, other=fail
30 data f3,f5,c5,3e,0f,d3,a0,3e,80,d3,a1,3e,0e,d3,a0,db,a2,0f,0f,0f,0f,e6,03,47,3e,0f,d3,a0,3e,8f,d3,a1,3e,0e,d3,a0,db,a2,0f,0f,e6,0c,b0,32,00,d0,c1,f1,fb,c9
31 l=49:restore30:gosub20:x=usr0(0):t(10)=peek(b)
39 't(1): dvik's v9938 test: 1=MSX2, 0=MSX1
40 data f3,f5,c5,af,32,00,d0,db,99,fb,76,f3,cd,13,d0,c1,f1,fb,c9,db,99,00,00,db,99,f5,3e,01,d3,99,3e,8f,d3,99,00,00,00,db,99,f5,af,d3,99,3e,8f,d3,99,f1,c1,b8,c8,3e,01,32,00,d0,c9
50 l=56:restore40:gosub20:x=usr0(0):screen0:t(1)=peek(b)
70 't(2): 4k/16k addresslines scrambled test: 1=91xx, 0=99xx
80 screen2:vpoke128,1:vdp(1)=vdp(1)xor128:t(2)=vpeek(128):vdp(1)=vdp(1)xor128:screen0
90 't(3): 2nd slotregister test: 1=yes, 0=no
100 i=peek(-1):j=ixor255:poke-1,j:j=peek(-1):ifi=jthent(3)=1elset(3)=0
110 's1$: SCF/CCF (+ s3$ CPL) test: 01ED29ED01FC29FC=zilog/sharp/sgs, 01C501ED01D401FC=nec, 01ED09ED01FC09FC=turboR, other=dunno. CPL: 3AFF12D7=standard, other=dunno
120 data f3,f5,c5,e5,21,00,d0,01,00,00,cd,24,d0,01,ff,00,cd,24,d0,01,00,ff,cd,24,d0,01,ff,ff,cd,24,d0,e1,c1,f1,fb,c9,c5,f1,37,f5,c1,71,23,c9'f1 37 c5 to f1 3f c5 for ccf .. to f1 2f c5 for cpl
130 l=43:restore120:gosub20:x=usr0(0):s1$="":fori=0to3:s1$=s1$+string$(2-len(hex$(peek(b+i))),"0")+hex$(peek(b+i)):next:l=43:restore120:gosub20:poke&hd026,&h3f:x=usr0(0):fori=0to3:s1$=s1$+string$(2-len(hex$(peek(b+i))),"0")+hex$(peek(b+i)):next
131 l=43:restore120:gosub20:poke&hd026,&h2f:x=usr0(0):s3$="":fori=0to3:s3$=s3$+string$(2-len(hex$(peek(b+i))),"0")+hex$(peek(b+i)):next
150 's2$: PSG mask test (regs 0-13): FFFFFFFFFFFFFFxxFFFFFFFFFFFF=YM2149. FF0FFF0FFF0F1Fxx1F1F1FFFFF0F=AY8910, FF1FFF1FFF1F1Fxx1F1F1FFFFF0F=AY8910 alternate, other=dunno (turboR has ay8910 mask, but envelope is like ym2149)
160 data f3,f5,3a,00,d0,d3,a0,3e,ff,d3,a1,db,a2,32,00,d0,f1,fb,c9
170 l=18:b=&hd001:restore160:gosub20:s2$="":fori=0to13:ifi<>7thenpokeb,i:x=usr0(0):s2$=s2$+string$(2-len(hex$(peek(b))),"0")+hex$(peek(b)):nextelses2$=s2$+"xx":next
180 sound8,0:sound9,0:sound10,0
190 't(4): vdp address latch test: 1=yes, 0=no
200 data f3,f5,db,99,c5,3e,00,d3,99,00,00,00,d3,99,01,4f,04,cd,30,d0,01,4c,03,cd,30,d0,01,4c,02,cd,30,d0,01,45,01,cd,30,d0,01,48,00,cd,30,d0,c1,f1,fb,c9,78,d3,99,00,00,79,d3,98,c9
210 screen2:l=56:restore200:gosub20:x=usr0(0):t(4)=vpeek(0):screen0:ift(4)=&h48thent(4)=0elset(4)=1
230 't(5): current ram slot (c000-ffff)
240 t(5)=inp(&ha8)\64
250 't(6): out (c),f aka out (c),0: 0=MSX, 255=turboR, other=dunno
260 data f3,f5,c5,01,a0,00,c5,ed,41,0c,ed,49,f1,ed,71,db,a2,32,00,d0,c1,f1,fb,c9
270 l=23:restore260:gosub20:x=usr0(0):t(6)=peek(&hd000)
280 't(7): check for sprite clones (unreliable due to heat, but a yes is reliable): 1=yes, 0=no
290 t(7)=0:screen2,3:sprite$(0)=string$(32,chr$(255)):vdp(4)=0:putsprite31,(0,0),15,0:putsprite0,(16,80),15,0:putsprite1,(16,144),15,0:onspritegosub300:spriteon:fori=0to999:next:spriteoff:vdp(4)=3:screen0:goto310
300 t(7)=1:spriteoff:return
310 'tests requiring user input (insert a goto to ignore)
320 't(8): check if screen2 mirrored mode works: 1=yes, 0=no
330 screen2:open"grp:"as#1:vdp(3)=159:vdp(4)=0:vdp(7)=20:preset(20,30):print#1,"see this text 3 times? (y/n)":gosub21:vdp(3)=255:vdp(4)=3:screen0:t(8)=c:fori=0to300:next
340 't(9): check if mode3 mixed mode works: 1=yes, 0=no
350 screen2:vdp(7)=21:line(0,0)-(255,191),15:fori=0to999:vdp(1)=vdp(1)xor16:next:vdp(7)=4:screen0:width37
360 print"did you see a white diagonal line    flickering with a bunch of black     smaller lines and a lighter blue bar?(y/n)":print
370 print"on TMS9xxx it's the above effect,    on V9938 it's a stable white diagonalline with a white bar scrolling up,  behaviour on other VDP models is     unknown":gosub21:cls:t(9)=c:fori=0to300:next
380 'show results
390 screen0:width37
400 print"dvik says VDP is V9938/58: ";:ift(1)=1thenprint"YES"elseprint"NO"
410 print"VDP 4k/16k has effect: ";:ift(2)=0thenprint"YES (TMS99xx)"elseprint"NO (TMS91xx)"
420 print"VDP has address latch: ";:ift(4)=1thenprint"YES (V99xx)"elseprint"NO (TMS9xxx)"
430 print"VDP sprite clones (?): ";:ift(7)=1thenprint"YES (TMS9xxx)"elseprint"NO (V99xx)"
440 print"VDP has screen 2 mirrored mode: ";:ift(8)=1thenprint"YES"elseprint"NO"
450 print"VDP has mode 3 mixed mode: ";:ift(9)=1thenprint"YES"elseprint"NO"
460 print"current RAM is in slot: ";hex$(t(5))
470 print"has secondary slot register: ";:ift(3)=1thenprint"YES"elseprint"NO"
480 print"Z80 scf: ";s1$;:ifs1$="01ED29ED01FC29FC"thenprint" (standard)"elseifs1$="01C501ED01D401FC"thenprint" (NEC)"elseifs1$="01ED09ED01FC09FC"thenprint" (turboR)"elseprint" (dunno)"
490 print"Z80 cpl: ";s3$;:ifs3$="3AFF12D7"thenprint" (standard)"elseprint" (dunno)"
500 print"Z80 out (c),0: ";hex$(t(6));:ift(6)=0thenprint" (MSX)"elseift(6)=255thenprint" (turboR)"elseprint" (dunno)"
510 print"PSG pin 6/7 quirk: ";hex$(t(10));:ift(10)=&hcthenprint" (YES)"elseift(10)=&hfthenprint" (NO)"elseprint" (dunno)"
520 print"PSGmask: ";s2$;:print"PSGmask (continued): ";:ifs2$="FFFFFFFFFFFFFFxxFFFFFFFFFFFF"thenprint"YM2149"elseifs2$="FF0FFF0FFF0F1Fxx1F1F1FFFFF0F"thenprint"AY8910"elseifs2$="FF1FFF1FFF1F1Fxx1F1F1FFFFF0F"thenprint"AY8910 alternate"elseprint"dunno"
