Author Topic: Screen copying/switching once again (BASIC)  (Read 814 times)

0 Members and 1 Guest are viewing this topic.

Offline SkulleateR

  • CPC6128
  • ****
  • Posts: 218
  • Country: de
  • Liked: 125
  • Likes Given: 69
Screen copying/switching once again (BASIC)
« on: 10:54, 22 June 20 »
Hi folks,


I know there are many topics about this and yes, I've read all of them and still I quite don't get it ....


Ok, so I know you can change screen address from &C000 to &4000 to switch screen mem, so far so good.


What I want to do :


- Load my program
- draw a map on screen (&C000)
- copy it to &4000 so I don't have to draw it again
- when an event is happening in the game : clear screen, put information there (print/draw/plot/whatever)
- after the event, copy the map back from &4000 to &C000


The point is to let the visible screen always be the one I write to ....


something like this :


Code: [Select]
10 DRAW map
20 main loop
30 event : copy screen to &4000
40 print information on visible screen
50 copy screen back from &4000 to &C000



Well you get the idea I hope  :P



Guess I use OUT &BC00 and &BD00 for this but everything I tried did not work at all :(  HELP :picard:

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: Screen copying/switching once again (BASIC)
« Reply #1 on: 11:43, 22 June 20 »
You could simply draw the map screen to &4000 and leave it there couldn't you?


The advantage of having it at &4000 being able to store in the upper 64k with a OUT &7F00,&C4 -> &C7 for example and with a SCR SET BASE set to &4000 and the appropriate Bank Area set to where the Map is, it wouldn't need to be moved anywhere (which is slow), or am I missing the point?
* 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

Offline SkulleateR

  • CPC6128
  • ****
  • Posts: 218
  • Country: de
  • Liked: 125
  • Likes Given: 69
Re: Screen copying/switching once again (BASIC)
« Reply #2 on: 11:57, 22 June 20 »
Can't do it that way, the map is used and altered in some minor ways, so I need to capture the state at that particular moment.


Speed isn't an issue here ....

Offline Sykobee (Briggsy)

  • 6128 Plus
  • ******
  • Posts: 814
  • Country: gb
  • Liked: 307
  • Likes Given: 473
Re: Screen copying/switching once again (BASIC)
« Reply #3 on: 12:04, 22 June 20 »
You can render the map changes to &4000 bank, or are you using firmware/library that assumes the screen is at &c000 so updates have to be done to that memory area?


Offline SkulleateR

  • CPC6128
  • ****
  • Posts: 218
  • Country: de
  • Liked: 125
  • Likes Given: 69
Re: Screen copying/switching once again (BASIC)
« Reply #4 on: 12:18, 22 June 20 »
As stated in the title, I'm using plain Loco Basic, I'm not into ASM ...




Offline Sykobee (Briggsy)

  • 6128 Plus
  • ******
  • Posts: 814
  • Country: gb
  • Liked: 307
  • Likes Given: 473
Re: Screen copying/switching once again (BASIC)
« Reply #5 on: 12:30, 22 June 20 »
I suspect you should not worry about the &4000 screen in that case and redraw it. If you can assume 128KB machine then you could store it in one of those banks and copy it in.


Why can't you use a &4000 screen with BASIC? Because BASIC thinks that memory is its memory pool.

 > Basic starts at &170 and grows up to HIMEM. HIMEM is set around &b0ff for 464
https://www.cpcwiki.eu/forum/amstrad-cpc-hardware/memory-map/msg100865/#msg100865


I guess you could use MEMORY &3FFF to change HIMEM underneath.
« Last Edit: 12:32, 22 June 20 by Sykobee (Briggsy) »

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Re: Screen copying/switching once again (BASIC)
« Reply #6 on: 13:34, 22 June 20 »
It's certainally possible to fool BASIC into thinking it's displaying something to a visible screen, @HAL 6128 posted a Bouncing Ball in BASIC, though it involves POKEing different addresses depending on which machine is used. I think peek(6) is good enough for that, which returns 128 for a 464, so the value becomes &B1CB and everything else has it set at &B7C6.


Code: [Select]
100 MODE 0
110 DEFINT a-z
120 IF PEEK(6)=128 THEN m=&B1CB ELSE m=&B7C6
130 c=0:b=&40:x=100
140 WHILE c<>10
150   b=&100-b:POKE m,b:CLS
160   y=100:GOSUB 200
170   x=x+4:c=c+1
180   OUT &BCFF,12:OUT &BDFF,b\4
190 WEND:PEN 1:MODE 2:END
200 MOVE x,y:DRAW x+100,y,1:DRAW x+100,y+100:DRAW x,y+100:DRAW x,y:RETURN


This is just a little Animated Square sequence which alternates between &4000 and &C000 screens, the POKE in line 150 is used to switch between screens without letting BASIC know about it and line 160 DRAWs the lines on the other screen. Line 180 is used to switch Screens and make the other screen visible. If that's of any help.
* 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