CPCWiki forum

General Category => Programming => Topic started by: eto on 21:16, 05 July 21

Title: how to identify the CPC model in Assembler?
Post by: eto on 21:16, 05 July 21
Since I recognised that there are different firmware calls for 464 and 6128 I was wondering, how I can identify which model my code is running on, but I failed to find that anywhere.

So, how do I know if my code is running on a 464 or a 6128 so that I can call the correct address. How can I easily know if it's a Plus?

And what happens if a 464 has been updated to a Basic 1.1 ROM (like the Spanish 472 e.g.). Will the firmware addresses then be identical to the 6128?
Title: Re: how to identify the CPC model in Assembler?
Post by: SRS on 21:47, 05 July 21
Früher (TM) we used this:

Code: [Select]
if peek(6)=128 then ?"I am a glorious 464" else if peek(6)=145 print "Sorry only 6128 ..."
or

Code: [Select]
10 '***********************************
20 '* RAMTEST and MACHINE TYPE routine*
30 '* by Rob Scott *
40 '***********************************
50 '
60 code=&8000
70 FOR a=&8000 TO &803E:READ c$
80 POKE a,VAL("&"+c$):NEXT
90 CALL code:CALL code+3
110 machine=PEEK(code+&3E)
120 ramyes=PEEK(code+&3D)
140 END
150 DATA C3,06,80,C3,33,80,21,00,40,3E
160 DATA C4,06,7F,ED,79,77,3E,C0,ED,79
170 DATA 3E,C4,ED,79,AF,7E,FE,C4,CA,29
180 DATA 80,D6,04,ED,79,3E,00,32,3D,80
190 DATA C9,D6,04,ED,79,3E,01,32,3D,80
200 DATA C9,0E,00,CD,15,B9,7C,32,3E,80
210 DATA C9,00,00
Title: Re: how to identify the CPC model in Assembler?
Post by: dragon on 22:06, 05 July 21
If is only theme of adjusting calls directions there is not needed of  detect the computer...




Imagine you have call &bd00


And there is the typical rst 08 5f 43


Check it. Is 08 5f 43 there? No, this is another firmware, check another know localization.


Also to the theme of basic,there are some subrevisions that can be checked, i m not sure if the 472 mount only one for them.


Gx4000 can be detected alone with the printer.


And plus can be detected with the asic.








Title: Re: how to identify the CPC model in Assembler?
Post by: andycadley on 00:08, 06 July 21
The official firmware jumpblock entry points should only vary with the difference between BASIC 1.0 and 1.1, so that should be all you need to detect. If you start wanting to play around inside other BASIC structures and unofficial entry points then there may be more need to look for other versions but I'm not sure about that.
Title: Re: how to identify the CPC model in Assembler?
Post by: zhulien on 03:37, 06 July 21
A cool project could be to make an Ultimate CPC Hardware detector.


CPC model
BASIC ver
Total RAM (DkTronics, Zaxon 4Mb, Toto 1Mb, Multiface 2, Rombo Vidi) all non-destructive so detection can be run at any time...
Total ROMS
Any other hardware added that is detectable

Title: Re: how to identify the CPC model in Assembler?
Post by: GUNHED on 03:58, 06 July 21
That's kind of what ROManager 2.37 does. But back to topic.

ROMs can be exchanged, so:
- Test for 64 KB RAM only
- Test for presence of FDC
- Test for RAM banking
- Test for Plus features

All that together is not 100% perfect, but can help.
Title: Re: how to identify the CPC model in Assembler?
Post by: eto on 10:45, 06 July 21
Früher (TM) we used this:

if peek(6)=128 then ?"I am a glorious 464" else if peek(6)=145 print "Sorry only 6128 ..."


Nice. thanks. Is this actually 464 vs 6128 or Basic 1.0 vs 1.1?

And would you have the assembler source code for the other example?
Title: Re: how to identify the CPC model in Assembler?
Post by: eto on 10:47, 06 July 21
Also to the theme of basic,there are some subrevisions that can be checked, i m not sure if the 472 mount only one for them.

Are the subrevisions documented somewhere? Probably not really relevant usually, but just for curiosity I would be interested which revisions exist and what the differences are.
Title: Re: how to identify the CPC model in Assembler?
Post by: dragon on 16:01, 06 July 21
Despite the fact that the Locomotive BASIC keeps displaying 1.1 on startup, several revisions exist if we refer to the ROM header:
CPC664 (v1.10) (https://www.grimware.org/lib/exe/fetch.php/documentations/hardware/amstrad.cpc/roms/basic.v1.1.cpc.664.zip)


[size=0px]KL_ROM_RESTORE   equ &B90C KL_ROM_SELECT   equ &B90F   org &4000   ; Select and enable Upper ROM 0 (BASIC)ldc,0call KL_ROM_SELECT pushbc   ; (&C001) = Mark number; (&C002) = Version number; (&C003) = Revision levelldhl,&C001ldde,&0000ldbc,3ldir   ; Restore previous Upper ROM statepopbclda,bcall KL_ROM_SELECT jp KL_ROM_RESTORE[/size][size=0px][/color][/size][size=0px][/color]10 MODE 2:FOR i=0 TO 24:READ a:POKE &4000+i,a:NEXT:CALL &4000 20 PRINT"Version ";PEEK(0);".";(PEEK(1)*10+PEEK(2)) 30 DATA &0E,&00,&CD,&0F,&B9,&C5,&21,&01 40 DATA &C0,&11,&00,&00,&01,&03,&00,&ED 50 DATA &B0,&C1,&78,&CD,&0F,&B9,&C3,&0C 60 DATA &B9[/size]



Title: Re: how to identify the CPC model in Assembler?
Post by: GUNHED on 02:03, 07 July 21
  • CPC6128 (v1.20) (https://www.grimware.org/lib/exe/fetch.php/documentations/hardware/amstrad.cpc/roms/basic.v1.2.0.cpc.6128.zip)
  • CPC6128 (v1.21) (https://www.grimware.org/lib/exe/fetch.php/documentations/hardware/amstrad.cpc/roms/basic.v1.2.1.cpc.6128.zip)
  • CPC6128 (v1.23) (https://www.grimware.org/lib/exe/fetch.php/documentations/hardware/amstrad.cpc/roms/basic.v1.2.3.cpc.6128.zip)


    Well, I can't open the archives. Can somebody please compare them?
    Title: Re: how to identify the CPC model in Assembler?
    Post by: eto on 17:37, 07 July 21
    Well, I can't open the archives.

    me neither. not sure what format that should be, it's not a valid ZIP
    Title: Re: how to identify the CPC model in Assembler?
    Post by: dragon on 23:06, 07 July 21
    Checks your roms and view versions :).