News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

How to get screen MODE?

Started by litwr, 21:11, 11 September 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

litwr

What is the best way to get it?  I am going to use PEEK(&b7c3)... However it will not work with CPC464 or maybe with PLUS models.  :( Thanks.

SRS

not sure if it works on all cpc, but this may help:

CALL &BC11

SCR GET MODE
ActionGets the current screen mode
EntlyNo entry conditions
ExitIf the mode is 0, then Carry is true, Zero is false, and A contains 0; if the mode is 1, then Carry is false, Zero is true, and A contains 1; if the mode is 2, then Carry is false, Zero is false, and A contains 2; in all cases the other flags are corrupt and all the other registers are preserved

AMSDOS

I'm assuming @litwr wants to get the screen mode without using the Firmware, though those Addresses mean nothing if the Firmware is disabled, though I was wondering how one detects which CPC is being used years ago, which this thread has a pile of answers in it.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

andycadley

Quote from: AMSDOS on 10:29, 12 September 16
I'm assuming @litwr wants to get the screen mode without using the Firmware, though those Addresses mean nothing if the Firmware is disabled, though I was wondering how one detects which CPC is being used years ago, which this thread has a pile of answers in it.
You can't find out from the hardware, the only way is to keep track of what value you last sent to the gate array (which is how the firmware call knows). If you need to know what mode you're in from something that is going to disable the firmware (but doesn't reset the mode itself) then you'll need to call SCR GET MODE before disabling the firmware and then keep that value up to date yourself.

litwr

I want to get this mode inside Basic program.  The call to &BC11 looks a bit difficult... How to use these flags in Basic?  It is a bit odd that fine Locomotive Basic misses a useful statement. :( Commodore Basics above 3.5 have RGR statement for this.

CECPC

Quote from: litwr on 11:54, 12 September 16
I want to get this mode inside Basic program.  The call to &BC11 looks a bit difficult... How to use these flags in Basic?  It is a bit odd that fine Locomotive Basic misses a useful statement. :( Commodore Basics above 3.5 have RGR statement for this.
If the address is common for all CPC Basic versions...

CpcAlive is a programming environment Amstrad CPC compatible.

Then &B7C3 should cointain MODE value.
Try with PEEK(&B7C3)

In any case, Firmware routine seems more secure. With a small assembler in the basic (memory+pokes) you should be able to read the value.

tastefulmrship

#6
Quote from: litwr on 11:54, 12 September 16
I want to get this mode inside Basic program.  The call to &BC11 looks a bit difficult... How to use these flags in Basic?  It is a bit odd that fine Locomotive Basic misses a useful statement. :( Commodore Basics above 3.5 have RGR statement for this.
Try this... I've tested it on my own 6128 (and WinAPE), but not on any other CPC!


10 MODE 1
20 FOR Address=&A000 to &A007
30 READ Byte$
40 POKE Address,VAL("&"+Byte$)
50 NEXT Address
60 CALL &A000
70 ScreenMode=PEEK(&A007)
80 PRINT "MODE";ScreenMode
90 END
100 DATA CD,11,BC,32,07,A0,C9,00


Change line 10 to whichever MODE you want to test! ENJOY!

EDIT: The assembler code incase anyone is wondering! (Not as if it's difficult to work out! ^_^)


        org    &a000

        call    &bc11
        ld    (Address),a
        ret

.Address    defb    &00

andycadley

Well, it looks like SuTeKH has beaten me to it, but I'll post my version as the M/C is fully relocatable which might be useful to some.


10 gosub 9000 : rem setup routine
20 let m% = 0
30 call getmode, @m%
40 print m%
50 end
9000 symbol after 256
9010 let getmode = himem - 11
9020 memory getmode -1
9030 restore 9090
9040 for i% = 0 to 10
9050 read x%
9060 poke getmode + i%, x%
9070 next i%
9080 return
9090 data &cd,&11,&bc,&dd,&6e,&00,&dd,&66,&01,&77,&c9


And the assembly:

call &bc11
ld l,(ix+0)
ld h,(ix+1)
ld (hl),a
ret

PulkoMandy


And here is a "pure BASIC" solution, just for fun:


10 POKE &C000,0
30 PLOT 0,400,15
40 a=PEEK(&C000)



This will make the firmware draw a pixel at the top left of the screen, using pen 15. Depending on the mode, the byte will have different values. We then read it using PEEK, and we test the value (&80 for mode 2, and I think &88 for mode 1 and &AA for mode 0).

Urusergi

A great trick  8) but it's out of range:


10 POKE &C000,0
30 PLOT 0,399,15
40 a=PEEK(&C000)

litwr

Thanks!  :) However it would be a bit better to have a proper word in Basic.  ;)

AMSDOS

Quote from: andycadley on 11:50, 12 September 16
You can't find out from the hardware, the only way is to keep track of what value you last sent to the gate array (which is how the firmware call knows). If you need to know what mode you're in from something that is going to disable the firmware (but doesn't reset the mode itself) then you'll need to call SCR GET MODE before disabling the firmware and then keep that value up to date yourself.

Looking at all the replies it appears there's all sorts of tricks you could do to find out the screen mode.  :)
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

arnoldemu

Quote from: litwr on 17:18, 12 September 16
Thanks!  :) However it would be a bit better to have a proper word in Basic.  ;)
i there a basic command to make a sprite and move it on the screen in commodore basic?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

andycadley

Quote from: litwr on 17:18, 12 September 16
Thanks!  :) However it would be a bit better to have a proper word in Basic.  ;)

I assume the thinking was that since the graphics commands in Basic are meant to be resolution independent, there would be little call for actually knowing the screen mode via a command.

Quote from: AMSDOS on 20:33, 12 September 16
Looking at all the replies it appears there's all sorts of tricks you could do to find out the screen mode.  :)

They all fundamentally rely on the fact the firmware is keeping track of the mode, if it wasn't then PLOT wouldn't be able to write different values to the display depending upon the current mode. The hardware itself doesn't provide any mechanism for determining a change "after the fact"

andycadley

Quote from: arnoldemu on 20:39, 12 September 16
i there a basic command to make a sprite and move it on the screen in commodore basic?

POKE. :P

But then the C64 doesn't actually have any graphics commands in basic at all! Things like RGR appear on later machines like the Plus 4, which didn't have sprites IIRC.

arnoldemu

Quote from: andycadley on 20:51, 12 September 16
POKE. :P

But then the C64 doesn't actually have any graphics commands in basic at all! Things like RGR appear on later machines like the Plus 4, which didn't have sprites IIRC.
exactly!

CPC Basic lacks RGR, and Commodore BASIC lacks basic commands for sprites!
So neither BASIC is perfect.  :D



My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

AMSDOS

Quote from: andycadley on 20:48, 12 September 16

They all fundamentally rely on the fact the firmware is keeping track of the mode, if it wasn't then PLOT wouldn't be able to write different values to the display depending upon the current mode. The hardware itself doesn't provide any mechanism for determining a change "after the fact"

Yep, so the screen mode would have to be obtained before disabling the firmware. Normally you would only do this if you wanted to return back to BASIC in the mode it was in usually. Using the hardware has little need for it, which I presume the reason why it hasn't got it.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

litwr

Quote from: arnoldemu on 20:39, 12 September 16
i there a basic command to make a sprite and move it on the screen in commodore basic?
C16/+4 have no hardware sprites  (so as CPC6128).  C128 Basic has such commands.  Locomotive Basic is fast but misses several good commands.
I used CPC6128, PCW8256 and PCW9512.   :)  They are good PC, maybe the best z80 based PC.  The problem of 6502/6809 based PC that they might be better but were often restricted artificially.  For example, C128 might be 2 times faster and use 256 KB memory.  Z80 had much better support...  IMHO it was a bit unfair.

ZbyniuR

Pure BASIC solution for any CPC:

10 IF PEEK(&BB5B)=0 THEN m=PEEK(&B1C8) ELSE m=PEEK(&B7C3)

In STARS, TREK is better than WARS.

Powered by SMFPacks Menu Editor Mod