Author Topic: How to get screen MODE?  (Read 856 times)

0 Members and 1 Guest are viewing this topic.

Offline litwr

  • CPC664
  • ***
  • Posts: 143
  • Country: ru
    • lidovski's www page
  • Liked: 113
How to get screen MODE?
« on: 23:11, 11 September 16 »
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.

Offline SRS

  • Supporter
  • 464 Plus
  • *
  • Posts: 447
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 391
Re: How to get screen MODE?
« Reply #1 on: 23:17, 11 September 16 »
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

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.336
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 605
Re: How to get screen MODE?
« Reply #2 on: 12: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.

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 728
  • Liked: 292
Re: How to get screen MODE?
« Reply #3 on: 13:50, 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.

Offline litwr

  • CPC664
  • ***
  • Posts: 143
  • Country: ru
    • lidovski's www page
  • Liked: 113
Re: How to get screen MODE?
« Reply #4 on: 13: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.

Offline CECPC

  • CPC464
  • **
  • Posts: 37
  • Country: es
  • Liked: 18
Re: How to get screen MODE?
« Reply #5 on: 14:19, 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.

Offline SuTeKH/Epyteor

  • 6128 Plus
  • ******
  • Posts: 1.164
  • Country: 00
  • Pure 6128 only... anything else is just $#!+
  • Liked: 1020
Re: How to get screen MODE?
« Reply #6 on: 14:22, 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!

Code: [Select]
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! ^_^)

Code: [Select]
        org    &a000

        call    &bc11
        ld    (Address),a
        ret

.Address    defb    &00
« Last Edit: 14:40, 12 September 16 by SuTeKH/Epyteor »

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 728
  • Liked: 292
Re: How to get screen MODE?
« Reply #7 on: 14:49, 12 September 16 »
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.

Code: [Select]
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:
Code: [Select]
call &bc11
ld l,(ix+0)
ld h,(ix+1)
ld (hl),a
ret

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 331
  • Country: fr
  • Liked: 253
Re: How to get screen MODE?
« Reply #8 on: 15:04, 12 September 16 »

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

Code: [Select]
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).

Offline Urusergi

  • CPC664
  • ***
  • Posts: 114
  • Country: es
  • Liked: 162
Re: How to get screen MODE?
« Reply #9 on: 17:05, 12 September 16 »
A great trick  8) but it's out of range:

Code: [Select]
10 POKE &C000,0
30 PLOT 0,399,15
40 a=PEEK(&C000)