Author Topic: (How) Is it possible to draw offscreen and swap into screen memory (BASIC)  (Read 1390 times)

0 Members and 1 Guest are viewing this topic.

Offline robbarton

  • Supporter
  • CPC6128
  • *
  • Posts: 152
  • Country: gb
  • Liked: 276
  • Likes Given: 54
While I've been preparing the type-ins for the wiki I've been looking at the code and have got a bit of inspiration to make something myself.

I've managed to get a converted jpg to display (my "loading screen"!) by loading a .SCR file to &C000, with a piece of converted midi music loading at &8000.

I wondered if it was possible to modify AA93's animator program and lift the snowstorm section into standalone code (lines 420-590 and 1550-1620), then do something clever to draw it off-screen (currently it draws on the screen then animates which is too slow and messy for me) and only switch the drawn snowstorm into the screen after the computations are done.

Basically I want to end up with a page of text (my "demo message") with a snowstorm effect over the top. Is that possible and if so, how?

I was guessing that line 490 needs something to say "start writing to memory at this off-screen address" e.g. &4000?, do all the plotting and calculations, then at line 1600 (is this where the calculations have completed?) do the switch over from &4000 to &C000 (is that right)? I'm not sure how to swap memory blocks, I looked at Bankman and hoped there was an easier way than by loading RSXs. I tried using the OUT command but didn't get anywhere.

Any advice will be appreciated, thank you.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924

I've had a look at the program you're referring too, which is Plotting a series of points, apart from INK 0, INKs 1-15 are being used to simulate the movement of the snow, which is the most effective effect in Interpreted BASIC. Lines 1550-1620 simulate the movement through the rotation of the INK palette. To make the program 464 Compatible replace the FRAME in 1600 with CALL &BD19, though IMO Frame Flyback isn't necessary when Rotating the INK palette, in this program though it's probably slowing the effect.


You can use the Firmware to select where the screen is, but I don't think the Firmware allows you to draw to the other screen while you're viewing the other, @HAL6128 posted a Bouncing Ball demo in the Hisoft Pascal 4t thread which demonstrated the use of OUT to draw the next ball position while displaying the previous ball position onscreen. Though there were complications when getting that small program to run on a 464 & 6128. Were you trying to utilise 2 Screens to have no delay?






If the Text your writing to screen is in a single colour you could reserve one of the INKs for your text, which will still give you 14 INKs to play with. If you wanted INK 15 for your text (I forgot to mention the Animator program begins in MODE 1, but uses MODE 0 for the effects), you could change line 630 to:


Code: [Select]
630 c%=int(rnd*14)+1

510 should read:


Code: [Select]
510 if c%=15 then c%=1

those other lines need changing as well:


Code: [Select]
1570 INK (a% MOD 14)+1,0
1590 INK (a% MOD 14)+1,c%
* 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 SuTeKH/Epyteor

  • 6128 Plus
  • ******
  • Posts: 1.386
  • Country: 00
  • Liked: 1297
  • Likes Given: 2033
While I've been preparing the type-ins for the wiki I've been looking at the code and have got a bit of inspiration to make something myself.

I've managed to get a converted jpg to display (my "loading screen"!) by loading a .SCR file to &C000, with a piece of converted midi music loading at &8000.

I wondered if it was possible to modify AA93's animator program and lift the snowstorm section into standalone code (lines 420-590 and 1550-1620), then do something clever to draw it off-screen (currently it draws on the screen then animates which is too slow and messy for me) and only switch the drawn snowstorm into the screen after the computations are done.

Basically I want to end up with a page of text (my "demo message") with a snowstorm effect over the top. Is that possible and if so, how?

I was guessing that line 490 needs something to say "start writing to memory at this off-screen address" e.g. &4000?, do all the plotting and calculations, then at line 1600 (is this where the calculations have completed?) do the switch over from &4000 to &C000 (is that right)? I'm not sure how to swap memory blocks, I looked at Bankman and hoped there was an easier way than by loading RSXs. I tried using the OUT command but didn't get anywhere.

Any advice will be appreciated, thank you.

I'm not too sure what the type-in program does, but if all it's doing is PLOT & DRAW commands, then there's an easy way to get the effect you're looking for!

Attached is an example. Type RUN"TWOSCRNS" to see it in action.

1. Load your title screen in lower memory (#4000-#7FFFF)
2. Show something on the upper screen (#C000-#FFFF)... and wait for a key press.
3. Instruct the CPC to view the lower screen. (OUT &BC00,&C:OUT &BD00,&10)
4. Because you haven't told the CPC that the screen memory is at #4000, all PLOT and DRAW commands still affect the upper screen memory!
5. When finished, go back to the upper screen to see the results. (OUT &BC00,&C:OUT &BD00,&30)

It should be pretty easy to apply this to your existing BASIC code.

Good luck,
- SuTeKH/Epyteor (aka JTMS)



Offline robbarton

  • Supporter
  • CPC6128
  • *
  • Posts: 152
  • Country: gb
  • Liked: 276
  • Likes Given: 54
Thank you for your replies.

@AMSDOS: I'm trying to load a picture and play some music while the snowstorm code does its calculations out of sight, then when the calculations are done clear the screen and show the message with the snowstorm superimposed on top. I'm trying to avoid drawing the coloured lines on the screen if possible - maybe it isn't possible to do that I'll have to go another way (some sort of pre-compiled binary loaded over the top of the message screen?)

@SuTeKH/Epyteor:  Thanks for the example, I'll give it a go and see if it suits my needs.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1157
  • Likes Given: 1924
Thank you for your replies.

@AMSDOS: I'm trying to load a picture and play some music while the snowstorm code does its calculations out of sight, then when the calculations are done clear the screen and show the message with the snowstorm superimposed on top. I'm trying to avoid drawing the coloured lines on the screen if possible - maybe it isn't possible to do that I'll have to go another way (some sort of pre-compiled binary loaded over the top of the message screen?)


Okay so it sounds like the second program @HAL 6128 posted here is the one which would help you. Unfortunately I don't recall all the particulars in order. The program does a poke to &B7C6 (which is a 6128 address which sets the SCR SET BASE, the screen is cleared and some drawing takes place and then some OUT commands are used OUT &BCFF,12:OUT &BDFF,b/4. The idea here I think is b=&40, divide that by 4 and you get &C0, divide it again and you get &40, but in that situation the program is displaying an image on screen, moving to the next in the animation sequence, which is one way to combat flickering.
I think what you need in your case is the OUT &BCFF,12:OUT &BDFF,&40, so you can load your Screen & Music first, do the OUT commands, then RUN your Animation program, which in theory will Draw your Multicoloured Pixels to &4000, once it's reached the INK rotation phase, POKE &B7C6,&40 or POKE &B1CB,&40 if it's a 464 in theory should display the Star field.


But I'm not 100% on this and won't be held liable if it damages your monitor, so it maybe prudent to read what someone might say about that methodology.

* 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