News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_keith56

how do I detect a CPC plus in assembly?

Started by keith56, 10:30, 13 December 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

keith56

I'm working on the hardware detect code for my game, and I need to identify the following 3 classes of machine :  Cpc 464 / Cpc 6128 / CPC 6128+

For 128k detection I am doing a bankswitch command and checking if the memory contents actually changed. (Note: I don't care about the firmware differences - I only need the extra ram)
For Plus detection I was going to do the same, using some code to turn on the ASIC, and copy a few bytes of ram at 4000 to 2000, and comparing them to the normal memory

The trouble is, when run on a non plus machine, the plus commands are switching on the firmware, which also resides around 2000, and my code thinks the machine is a plus when it is not - and then crashes!

Is there a better 'official' way to check if a machine is a CPC plus? it feels I am doing this wrong!

Thanks,

Keith
Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

Duke

You could check the basic ROM version to identify plus (v4 I think).

arnoldemu

Enable asic ram, write a byte to the sprite ram and see it's masked (high byte read is set to 0).
Do similar for some other bytes.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Ast

The Best Way to detect cpc plus without enabling cpc plus features will be using the ppi bug or the im2 mode.
More informations on QuasarNet, as always.

_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

andycadley

If your code to switch on the ASIC is paging in the Firmware, I suspect you have a bug in it somewhere. That's definitely the best way to do things.

keith56

Quote from: andycadley on 14:40, 13 December 16
If your code to switch on the ASIC is paging in the Firmware, I suspect you have a bug in it somewhere. That's definitely the best way to do things.

It only happens on the Non plus, the firmware stays off on a plus machine,

This is the command which causes it:
      ld bc,&7fb8
      out (c),c
It turns on the Asic memory on the plus, but on the non plus it turns on the firmware

I copied it, and the Plus-enable code from the sprite example on CPCWIKI!
Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

andycadley

Disable interrupts during testing and make sure your code+stack are in a "safe" space.

arnoldemu

Quote from: keith56 on 22:27, 13 December 16
It only happens on the Non plus, the firmware stays off on a plus machine,

This is the command which causes it:
      ld bc,&7fb8
      out (c),c
It turns on the Asic memory on the plus, but on the non plus it turns on the firmware

I copied it, and the Plus-enable code from the sprite example on CPCWIKI!
that is correct, cpc ignores bit 5 of the data (b8 in this case).
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

keith56

I got everything sorted, I copied my plus code from the examples without decoding what it did (as it worked on a plus)

I read through this article, and it made it all clear!:
http://cpctech.cpc-live.com/docs/arnold5a.html

I'm now using these commands to turn the asic on:
      ld bc,&7fb8
      out (c),c
      ld bc,&7f8C
      out (c),c
And these to turn it off:
      ld bc,&7fA8
      out (c),c
      ld bc,&7f8C
      out (c),c

They get the asic on/off , and end with everything in a good state for my code - the code doing this is around &FF00 - so turning on the lower rom doesn't hurt it.

I notice the Gate array page (Which I have printed and laminated as my idiots guide) says bit 5 is unused - maybe it should mention the new Asic function?
http://www.cpcwiki.eu/index.php/Gate_Array

Thanks for the help! I got there in the end!
Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

Ast


For the second and last time, There is no need to unlock asic to detect plus machine...
Here is the piece of code using in iMPdraw to detect if i'm on Amstrad Plus or Amstrad Cpc.


Just Try it and forget bad things !
This test is based on PPi reset.



ld bc,#F782
ld e,c
out (c),c
dec b
ld c,#0f
out (c),c
inc b
ld a,e
out (c),a
dec b
in a,(c)
cp c
jr z,CpcPlus
or a
jr z,CpcOld



Last words, when you said using this command to turn off the asic



ld bc,#7fa8
out (c),c



Don't you really know what you're doing ?
Page  Asic is deconnected but rom #87 is connected to the plage #0000-#3FFF


So, the correct way to turn off the asic will be :



ld bc,#7fa0 ; turn asic off and connect rom #80 into plage #0000-#3FFF
out (c),c



I really hope it would help you.
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

As I don't know what to do this afternoon, i wrote an article on Amstrad Plus Forum
Of course, this is only written in french language but remember one thing : "Google translate is your friend"


Thanks.
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

andycadley


I think that highlights why I don't particularly like it as a technique, you're detecting one thing and assuming something else based upon it which is inherently fragile (emulators may not behave correctly, revisions of CPCs or clones might be mis-detected etc.) Whereas with the "turn on the ASIC and check it exists" method you are literally testing the thing you want to use, a much more reliable mechanism.


What's more, you're presumably testing with the intention of using Plus features, so you're going to have the ASIC unlocking code available anyway, you may as well use it rather than keeping some other code around (especially given that following your test the very next step is liable to be Call UnlockASIC!)

Ast

#12
Quote from: andycadley on 20:32, 14 December 16
What's more, you're presumably testing with the intention of using Plus features, so you're going to have the ASIC unlocking code available anyway, you may as well use it rather than keeping some other code around (especially given that following your test the very next step is liable to be Call UnlockASIC!)
You'll be right if the final way would be to use Cpc Plus featuring.
-Delock Asic-Connect i/o Page-Poke any value in Asic Page (where we could read this value)-Deconnect i/o Page.


But just imagine, you wanna do a proggy who will have to work on all Cpc incluing the plus range. You have no obligation to delock Asic to know you're on an Amstrad Plus.


Delocking Asic must only be done when you want to use the "plus" mode. My goal was to propose you "a proper solution".


_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

roudoudou

Quote from: Ast on 20:56, 14 December 16
Delocking Asic must only be done when you want to use the "plus" mode. My goal was to propose you "a proper solution".


The proper solution is to ask the user  :P


Because maybe he will want to see the CPC version without plus feature, like prehistorik 2 for example. End user has the choice!
My pronouns are RASM and ACE

Skunkfish

I'm actually all in favour of a start-up option for this rather than detection, mainly because I'd be interested in trying both options on my 6128+ to see how they compare...
An expanding array of hardware available at www.cpcstore.co.uk (and issue 4 of CPC Fanzine!)

andycadley


Quote from: Ast on 20:56, 14 December 16
But just imagine, you wanna do a proggy who will have to work on all Cpc incluing the plus range. You have no obligation to delock Asic to know you're on an Amstrad Plus.
If it has to work on all CPC's, why would you need to detect a Plus machine? And none of the methods that don't involve unlocking the ASIC guarantee that you aren't using something else, they're all things that could be fooled by external hardware or that might fail on clones, emulators etc.

Ast

Quote from: andycadley on 19:25, 15 December 16
If it has to work on all CPC's, why would you need to detect a Plus machine? And none of the methods that don't involve unlocking the ASIC guarantee that you aren't using something else, they're all things that could be fooled by external hardware or that might fail on clones, emulators etc.
if you need to do a crtc adaptation, for example...
I'm thinking about iMPdraw, for the story... I need to do a crtc adaptation, so I need to know where i'm working...
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

dragon

#17
Taking apart the gx4000(i assume is a dsk aplication).

Is not possible detect if is a normal cpc or a plus detecting if it have 7 bit printer port or 8 bit?.

Only plus have 8 bit printer, even if you add 8 bit to the normal cpc they not are controlled by the Bit 3 of crtc Register 0Ch.

Just a Theory reading the arnold v especification.

"When installed (default), enables the 8th printer bit, controlled via CRTC Register 0Ch, Bit 3. When removed, outputs LOW as 8th bit (as on classic CPCs with 7bit printer port). See also: 8bit Printer Ports."

Ast

Quote from: dragon on 22:13, 15 December 16
Taking apart the gx4000(i assume is a dsk aplication).

Is not possible detect if is a normal cpc or a plus detecting if it have 7 bit printer port or 8 bit?.

Only plus have 8 bit printer, even if you add 8 bit to the normal cpc they not are controlled by the Bit 3 of crtc Register 0Ch.

Just a Theory reading the arnold v especification.

"When installed (default), enables the 8th printer bit, controlled via CRTC Register 0Ch, Bit 3. When removed, outputs LOW as 8th bit (as on classic CPCs with 7bit printer port). See also: 8bit Printer Ports."
iT would be a good idea but it won't work if you displayed a fullscreen picture.
Have you already forgotten the overscan bits ?
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

keith56

I think anything we do to detect a Plus / Non plus needs to work reliably on Emulators that do not support Plus features.

I would say most people playing CPC games are using emulators, and a great number of them do not have any CPC+ support - so any detection routine needs to detect as a Non plus and not crash on those emulators!

Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

dragon

#20
@ast mostly i don't know It.


Another question about detect  the Plus range. Is possible diference
where is the program running in the gx4000, the 6128+ or the 464+?.


You can detect a 6128+  or 464+ /gx4000 detecting the fdc controller, But is possible detect the cassette?. To diference between 464+/gx4000?. I speak about only plus range, executing  the Code from cartridge.


Maybe is possible detect gx4000 made some type of internal benchmark.(because the gx4000 is 0.25℅ slow.).


Or this can work:


1: select logical Page 07 in upper rom.
2: Load one byte of the ROM in a register.
3. Load pysicall Page 1 in upper rom.
4.Move a to b
5.load the same direction in upper ROM in register A.
6 a cp b.
7. If a and b registers are equal, then you are in the gx4000 jump to 8 else jump to 9. Restore ROM page to original.
8. Finish.gx4000 detected
9. 464+ or 6128+ detected. Detect fdd  controller
10 fdc detected 6128+ finished
11. No fdc 464+ detected finished.





About detect plus/not Plus funny  Mode. Write in screen calibrating joysticks please press XxX. Simultaneously.Then keyboard Clash=old range no Clash=plus.

Ast


Hi Dragon,

Detecting fastly 6128+ or 464+ and just read what you have in #0039.


If result is #41 you've a 6128 plus
If result is #39 your Cpc is a 464 plus
...
Detecting a gx4000 is more difficult ! The only thing i'm thinking is There is no basic rom on gx4000!
But, but, but... if you run anything on gx4000, it will probabily be a cpr rom. So this cpr rom will not countain the basic rom too... arg... good question...
If someone else Has any idea...



_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

Quote from: dragon on 09:42, 23 January 17
About detect plus/not Plus funny  Mode. Write in screen calibrating joysticks please press XxX. Simultaneously.Then keyboard Clash=old range no Clash=plus.
Please give me more informations about what you're writing because i don't really understand...


Detecting The rom7 or basic to know if you have a gx4000 or not will not Work...
Because all cpr rom are empty in The beginning.
If you're making some game, demo, tool, working on The range plus (in cartridge format), these roms won't be present !
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

Gx4000 has no keyboard... Maybe we could use this to isolate Gx4000.
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

arnoldemu

GX4000 will not respond to:

ld bc,&df07
out (c),c

On GX4000 you do not get cart page 3.

So try df07, and then df83 and compare some bytes. You will know if you have gx4000 or not.

Why do you need to specific check for gx4000?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Powered by SMFPacks Menu Editor Mod