Forum
Play on a bank ($c000) in spectrum128 and then copy to $4000 - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13)
+---- Thread: Play on a bank ($c000) in spectrum128 and then copy to $4000 (/showthread.php?tid=2594)



Play on a bank ($c000) in spectrum128 and then copy to $4000 - funkheld - 01-05-2025

Hello, good day.

How can you play on the $c000 area if you have the Specrum128 mode? You can assign the banks to $c000.

thanks.
greetings


RE: Play on a bank ($c000) in spectrum128 and then copy to $4000 - boriel - 01-09-2025

I don“t understand, sorry.
What are you trying to achieve? A Screen buffer?


RE: Play on a bank ($c000) in spectrum128 and then copy to $4000 - funkheld - 01-10-2025

how can you use $c000 as a screen?
can you print at $c000?
how can you direct the output to $c000 with asm?

thanks.
regards


RE: Play on a bank ($c000) in spectrum128 and then copy to $4000 - boriel - 01-10-2025

funkheld Wrote:how can you use $c000 as a screen?
can you print at $c000?
how can you direct the output to $c000 with asm?

thanks.
regards

Yes. All standard routines support printing and drawing in any RAM address ("standard" means, they came bundled with the compiler).
The same for attributes. You can draw attributes in a different region of the screen: this is useful if you want to use only a small buffer (i.e. 2/3 of the screen) and put the attributes just after that, so saving 2k of (scarce ram).

Code:
#include <scrbuffer.bas>
#include <memcopy.bas>

DIM scr_addr, attr_addr as UInteger

CLS: PRINT "PRESS A KEY"

scr_addr = GetScreenBufferAddr() : REM Original screen address ($4000)
attr_addr = GetAttrBufferAddr(): REM Original Attr address

SetScreenBufferAddr($C000)
SetAttrBufferAddr($C000 + 6144) :REM uses standard screen + attribute region

CLS: REM Clears new Screen (it may contain random bits)
PRINT INK 6; PAPER 1; "HELLO WORLD"

PAUSE 0
MemCopy(0xC000, scr_addr, 6144) : REM Copy only pixels region
PAUSE 0
MemCopy(0xC000 + 6144, attr_addr, 32 * 24): REM Copy attributes region

This example (untested, typed here directly), PRINTS in another region. Then copy (blits) the pixels to the actual screen and later the attributes.
If the buffer is in a contiguous region, you can copy all the buffer in one single MemCopy call.

EDIT: Program fixed and tested :-)


RE: Play on a bank ($c000) in spectrum128 and then copy to $4000 - funkheld - 01-12-2025

hello, thanks for your help.

it works great with print, plot and draw.

greetings