Quote from: ervin on 12:54, 11 February 24and that it's possible to use different 16KB banks of the extra RAM for double buffering.Please note that you can't use the extra 64K as video memory.
Quote from: Jean-Marie on 15:05, 11 February 24For a double buffer, I guess you could use the C7 setup, to have RAM7 windowed at offset 4000h, and switch the CRTC reading from C000h to 4000h.The CRTC will still display the content of the primary 64K. It can't access the extra ram.
Quote from: McArti0 on 08:39, 12 February 24best way to double buffer is C1, C3. Now you have two screen at the same place &4000-7FFF. BANKs 0,1,2,7 and 0,3,2,7 and work firmware.In my opinion, this configuration is not so practical if you want to use the extra 64kb.
Quote from: gurneyh on 10:58, 12 February 24It really depends on what you need the extra RAM for. C2 can work well with this in some situations. Or a small amount of code in RAM0 that access the rest via C4/5/6.Quote from: McArti0 on 08:39, 12 February 24best way to double buffer is C1, C3. Now you have two screen at the same place &4000-7FFF. BANKs 0,1,2,7 and 0,3,2,7 and work firmware.In my opinion, this configuration is not so practical if you want to use the extra 64kb.
Quote from: McArti0 on 08:39, 12 February 24best way to double buffer is C1, C3. Now you have two screen at the same place &4000-7FFF. BANKs 0,1,2,7 and 0,3,2,7 and work firmware.
Quote from: ervin on 14:15, 12 February 24And even then, if I then use C2 in order to bring in data or code from banks 4 to 6, will that mess up the screen display?
(As banks 1 and 3 will be switched out)
Quote from: eto on 14:39, 12 February 24Quote from: ervin on 14:15, 12 February 24And even then, if I then use C2 in order to bring in data or code from banks 4 to 6, will that mess up the screen display?
(As banks 1 and 3 will be switched out)
No, RAM banking won't mess up the screen display.
RAM banking only affects the CPU. The Gate Array will always access the first 64KB and always see data at exactly the same position. So if you e.g. set C3, the CPU will see RAM bank 3 at "virtual address" &4000 but the Gate Array will still access the same data at the physical address &C000. If the CPU writes e.g. 255 to &4000, the Gate Array will see that &255 at &C000.
Quote from: ervin on 15:03, 12 February 24That's very interesting! And certainly not what I expected.
#include <cpctelera.h>
void populateYaddress();
void checkInput();
void updateScreen();
void changeVideoMemoryPage();
void ramBankC1();
void ramBankC3();
void printVerticalLine();
void drawTile();
#define SCREEN_BUFFER (u8*)0x4000
const u8* pTile;
u8 ramBank;
u8 x;
u8 y;
__at(0x0200) u8* yAddress[200]; // 400 bytes MUST BE BYTE ALIGNED
__at(0x0400) const u8 tile[16]={ // 16 bytes MUST BE BYTE ALIGNED
0x44,0x22,0x44,0x22,0xE8,0x99,0xE8,0x99,0x22,0x44,0x22,0x44,0x88,0x40,0x88,0x40
};
void main(void) {
cpct_disableFirmware();
cpct_setStackLocation((u8*)0xC000);
cpct_memset_f64(CPCT_VMEM_START,0x00,0x4000);
cpct_setBorder(HW_BRIGHT_WHITE);
cpct_setVideoMode(0);
cpct_setVideoMemoryPage(cpct_pageC0);
ramBankC1();
ramBank=1;
populateYaddress();
while(1){
checkInput();
updateScreen();
changeVideoMemoryPage();
}
}
void populateYaddress(){
for (u8 i=0;i<200;i++){
yAddress[i]=cpct_getScreenPtr(SCREEN_BUFFER,0,i);
}
}
void checkInput(){
cpct_scanKeyboard_f();
if (cpct_isKeyPressed(Key_CursorLeft)){
x-=2;
}
if (cpct_isKeyPressed(Key_CursorRight)){
x+=2;
}
}
void updateScreen(){
cpct_waitVSYNC();
cpct_memset_f64(SCREEN_BUFFER,0x00,0x4000);
printVerticalLine();
}
void changeVideoMemoryPage(){
if (ramBank==1){
cpct_setVideoMemoryPage(cpct_page40);
ramBankC3();
ramBank=3;
}
else{
cpct_setVideoMemoryPage(cpct_pageC0);
ramBankC1();
ramBank=1;
}
}
void ramBankC1(){
__asm
ld b,#0x7f
ld c,#0xc1
out (c),c
__endasm;
}
void ramBankC3(){
__asm
ld b,#0x7f
ld c,#0xc3
out (c),c
__endasm;
}
void printVerticalLine(){
u8 px;
pTile=tile;
px=x;
for (u8 j=0;j<=2;j++){
for (u8 i=0;i<=24*8;i+=8){
y=i;
drawTile();
}
x+=4;
}
x=px;
}
void drawTile(){
__asm
ld de,(_pTile)
// vram=yAddress[y]+x/2;
ld hl,(_y)
ld h,#0x00
add hl,hl
ld bc,#_yAddress
add hl,bc
ld c,(hl)
inc l
ld b,(hl)
ld hl,(_x)
ld h,#0x00
srl l
add hl,bc
// ROW 1
ex de,hl
ldi
ldd
set 3,d
inc l
inc l
// ROW 2
ldi
ldd
set 4,d
res 3,d
inc l
inc l
// ROW 3
ldi
ldd
set 3,d
inc l
inc l
// ROW 4
ldi
ldd
set 5,d
res 4,d
res 3,d
inc l
inc l
// ROW 5
ldi
ldd
set 3,d
inc l
inc l
// ROW 6
ldi
ldd
set 4,d
res 3,d
inc l
inc l
// ROW 7
ldi
ldd
set 3,d
inc l
inc l
// ROW 8
ldi
ldd
ex de,hl
__endasm;
}
; soft in &4000 to &7fff only. call to all banks C4,C5,C6,C7 and return.
org #4000
ld de,1234 ; sample data
ld hl,#6000 ; sample adress to call
ld a,#c4 ;bank number
call far ;to c4
inc a
call far ;to c5
inc a
call far ;to c6
inc a
call far ;to c7
ret
org #7ff0
.far
ld bc,#7FC0
out (C),A
push BC
ld bc,return
push bc
jp (hl) ;call hl
.return
pop bc
out (C),C
ret
write direct -1,-1,#C4
;far
org #7ff0
ld bc,#7FC4
out (C),A
push BC
ld bc,return
push bc
jp (hl) ;call hl
;return
pop bc
out (C),C
ret
org #6000
ret
write direct -1,-1,#C5
;far
org #7ff0
ld bc,#7FC5
out (C),A
push BC
ld bc,return
push bc
jp (hl) ;call hl
;return
pop bc
out (C),C
ret
org #6000
ret
write direct -1,-1,#C6
;far
org #7ff0
ld bc,#7FC6
out (C),A
push BC
ld bc,return
push bc
jp (hl) ;call hl
;return
pop bc
out (C),C
ret
org #6000
ret
write direct -1,-1,#C7
;far
org #7ff0
ld bc,#7FC7
out (C),A
push BC
ld bc,return
push bc
jp (hl) ;call hl
;return
pop bc
out (C),C
ret
org #6000
ret
Quote from: GUNHED on 17:37, 16 February 24The coolest CPC Banking feature is RAM configuration &C3. It's like &C1, but in addition it moves the upper 16 KB block of the main RAM (usually Video-RAM) from &C000-&FFFF to &4000-&7FFF. That's used by CP/M Plus, FutureOS and some cool demos too.I can understand that C3 is the best mode to adapt a normal 64KB game to use double buffering on a 128KB machine as it requires minimal change to the original code, but why is C3 a benefit for games that take real advantage of 128K memory and more? There I would have expected that C3 is even slower as it's impossible to copy anything from RAM4,RAM5 and RAM6 to RAM 1 directly.
Quote from: eto on 09:52, 19 February 24There isn't really any combination that allows easy copying between RAM4/5/6 and RAM1. There is always going to be some compromises and carefully organising the memory map to fit your use case is crucial. The C1/C2/C3 configurations are often overlooked in favour of the "easier" methods that just page at #4000 though.Quote from: GUNHED on 17:37, 16 February 24The coolest CPC Banking feature is RAM configuration &C3. It's like &C1, but in addition it moves the upper 16 KB block of the main RAM (usually Video-RAM) from &C000-&FFFF to &4000-&7FFF. That's used by CP/M Plus, FutureOS and some cool demos too.I can understand that C3 is the best mode to adapt a normal 64KB game to use double buffering on a 128KB machine as it requires minimal change to the original code, but why is C3 a benefit for games that take real advantage of 128K memory and more? There I would have expected that C3 is even slower as it's impossible to copy anything from RAM4,RAM5 and RAM6 to RAM 1 directly.
Quote from: andycadley on 14:37, 19 February 24Sure, als we can see in the post before yours. In addition people tend to forget the mode &C3 was introduced to allow CP/M Plus to run on 128 KB CPCs.Quote from: eto on 09:52, 19 February 24There isn't really any combination that allows easy copying between RAM4/5/6 and RAM1. There is always going to be some compromises and carefully organising the memory map to fit your use case is crucial. The C1/C2/C3 configurations are often overlooked in favour of the "easier" methods that just page at #4000 though.Quote from: GUNHED on 17:37, 16 February 24The coolest CPC Banking feature is RAM configuration &C3. It's like &C1, but in addition it moves the upper 16 KB block of the main RAM (usually Video-RAM) from &C000-&FFFF to &4000-&7FFF. That's used by CP/M Plus, FutureOS and some cool demos too.I can understand that C3 is the best mode to adapt a normal 64KB game to use double buffering on a 128KB machine as it requires minimal change to the original code, but why is C3 a benefit for games that take real advantage of 128K memory and more? There I would have expected that C3 is even slower as it's impossible to copy anything from RAM4,RAM5 and RAM6 to RAM 1 directly.
Quote from: GUNHED on 19:58, 19 February 24people tend to forget the mode &C3 was introduced to allow CP/M Plus to run on 128 KB CPCs.Could you please share where I can find that information? I can only find information on the Wiki and in a book that CP/M plus is using C2 and C0. C3 was nowhere mentioned.
Quote from: eto on 20:37, 19 February 24In Chapter 8, Page 2 of the 6128 user manual you can read:Quote from: GUNHED on 19:58, 19 February 24people tend to forget the mode &C3 was introduced to allow CP/M Plus to run on 128 KB CPCs.Could you please share where I can find that information? I can only find information on the Wiki and in a book that CP/M plus is using C2 and C0. C3 was nowhere mentioned.
Quote from: d_kef on 00:58, 20 February 24#C3 contains a copy of the CCP, disk hash tables and data buffers.Thanks, interesting, I still wonder why this is required, when you have #C4-#C7 anyway.
Quote from: d_kef on 00:58, 20 February 24They also designed almost identical memory configurations for the PCW and the Spectrum +3.The PCW has a flexible 4x16K memory mapping. I don't know of any alternative CPC-like mapping. Even in "CPC mode" it is using independant 4x16K pages. Maybe you mixed it?
Quote from: Prodatron on 14:25, 20 February 24Thanks, interesting, I still wonder why this is required, when you have #C4-#C7 anyway.
Quote from: Prodatron on 14:25, 20 February 24Indeed the +2A/+3 memory mapping is using the same combinations like #C0-#C3:
Spectrum %00 -> same as -> CPC #C2
Spectrum %01 -> same as -> CPC #C0
Spectrum %10 -> same as -> CPC #C1
Spectrum %11 -> same as -> CPC #C3
(with blocks 0-3 and blocks 4-7 swapped).
Something like #C4-#C7 is missing on the Amstrad Spectrums.
Quote from: andycadley on 15:01, 20 February 24That's only the "all RAM" combinations. The paging system also allows any 16K page of the memory to be made visible at #C000 when the ROM is visible in the lower 16K.Yes, but then you can't have your own RSTs and interrupt handler, and 16K of visible RAM is missing :(
Quote from: Prodatron on 15:40, 20 February 24That's the Speccy way. :laugh:Quote from: andycadley on 15:01, 20 February 24That's only the "all RAM" combinations. The paging system also allows any 16K page of the memory to be made visible at #C000 when the ROM is visible in the lower 16K.Yes, but then you can't have your own RSTs and interrupt handler, and 16K of visible RAM is missing :(
Quote from: eto on 20:37, 19 February 24Well, it's common knowledge for me. You can look into Computer Journals, Google it or eventually use the Wiki. Sorry, I'm not the Silver Platter. My time is as precious as yours.Quote from: GUNHED on 19:58, 19 February 24people tend to forget the mode &C3 was introduced to allow CP/M Plus to run on 128 KB CPCs.Could you please share where I can find that information? I can only find information on the Wiki and in a book that CP/M plus is using C2 and C0. C3 was nowhere mentioned.
Quote from: Prodatron on 21:38, 19 February 24IIRC CP/M+ was using #C2 (for the 63K TPA) and #C1 for the "common area". And probably #C4-#C7 for managing/initialisation of the 2nd 64K bank.If CP/M Plus (Amstrad Version) would NOT require &C3, then it would run on CPC464 with RAM expansion. Later on CP/M Plus was patched to run on CPC464 too - by 3rd party developers. And before you ask: That's common knowledge, you can google it - Don't ask me for details, my time is as precious as yours.
Maybe the ROM-Part of Dr.Logo, which was placed in the second 8KB of the Amsdos ROM, was using #C3? But yes, that's not really CP/M(+) related, just another example that #C3 was designed for Rom software.
[this Dr.Logo for CP/M+ was a very strange oddity of Amstrad anyway: including a part of an alternative programming language in ROM, which still required booting another OS from disc + the remaining part of the programming language, and which wasn't used at all by most of the users :) ]
Quote from: GUNHED on 18:01, 20 February 24Well, it's common knowledge for me. You can look into Computer Journals, Google it or eventually use the Wiki. Sorry, I'm not the Silver Platter. My time is as precious as yours.I searched Google, I checked the Wiki, I looked into the Markt&Technik book about CP/M and they all mention C2 but not C3.
Quote from: d_kef on 00:58, 20 February 24In "The Amstrad CP/M Plus" by David Powys-Lybbe & Andrew R M Clarke, page 433 you can read a detailed description of the usage of modes #C1 to #C3.awesome. Thanks a lot.
#C1 contains the banked portions of the BIOS and BDOS, the screen memory, disk buffers and the extended BIOS jumpblock.
#C2 is the TPA bank in which all application programs are run.
#C3 contains a copy of the CCP, disk hash tables and data buffers.
It is obvious that Amstrad designed memory modes #C1, #C2 and #C3 specifically for use with CP/M Plus so that the upper 16K of memory (block 7) is common to all 3. A prerequisite of the banked version of CP/M Plus.
They also designed almost identical memory configurations for the PCW and the Spectrum +3.
Quote from: ZorrO on 21:13, 20 February 24Is it C3 work on normal 6128, or on Plus only?Normal 6128.
Quote from: eto on 19:26, 20 February 24Yes, the wiki sadly lacks a lot of basic information. Thanks to d_key - who gave a reference - it shall become common knowledge here too. :) :) :)Quote from: GUNHED on 18:01, 20 February 24Well, it's common knowledge for me. You can look into Computer Journals, Google it or eventually use the Wiki. Sorry, I'm not the Silver Platter. My time is as precious as yours.I searched Google, I checked the Wiki, I looked into the Markt&Technik book about CP/M and they all mention C2 but not C3.
So it obviously isn't common knowledge as otherwise it would be present e.g. on the Wiki.
But no worries, d_kef already answered.
Quote from: ZorrO on 21:13, 20 February 24Is it C3 work on normal 6128, or on Plus only?CPC6128 and 6128plus natively. CPC464 and CPC664 with Revaldhinos RAM expansion (not the other ones though).
Quote from: Prodatron on 14:25, 20 February 24The PCW has a flexible 4x16K memory mapping. I don't know of any alternative CPC-like mapping. Even in "CPC mode" it is using independant 4x16K pages. Maybe you mixed it?
Z80 address space | CP/M Bank 0 | CP/M Bank 1 | CP/M Bank 2 |
#C000-#FFFF | RAM page 7 common | RAM page 7 common | RAM page 7 common |
#8000-#BFFF | RAM page 3 BIOS,BDOS | RAM page 6 TPA | (RAM page 3) |
#4000-#7FFF | RAM page 1 screen | RAM page 5 TPA | RAM page 8 CCP,hash tables, data buffers |
#0000-#3FFF | RAM page 0 BIOS jumpblock | RAM page 4 TPA | (RAM page 0) |
Z80 address space | CP/M Bank 0 | CP/M Bank 1 | CP/M Bank 2 |
#C000-#FFFF | RAM page 7 common | RAM page 7 common | RAM page 7 common |
#8000-#BFFF | RAM page 2 BIOS,BDOS | RAM page 6 TPA | (RAM page 2) |
#4000-#7FFF | RAM page 1 screen | RAM page 5 TPA | RAM page 3 CCP,hash tables, data buffers |
#0000-#3FFF | RAM page 0 BIOS jumpblock | RAM page 4 TPA | (RAM page 0) |
Z80 address space | CP/M Bank 0 | CP/M Bank 1 | CP/M Bank 2 |
#C000-#FFFF | RAM page 3 common | RAM page 3 common | RAM page 3 common |
#8000-#BFFF | RAM page 6 BIOS,BDOS | RAM page 2 TPA | (RAM page 6) |
#4000-#7FFF | RAM page 5 screen | RAM page 1 TPA | RAM page 7 CCP,hash tables, data buffers |
#0000-#3FFF | RAM page 4 BIOS jumpblock | RAM page 0 TPA | (RAM page 4) |
Quote from: Prodatron on 21:38, 19 February 24IIRC CP/M+ was using #C2 (for the 63K TPA) and #C1 for the "common area". And probably #C4-#C7 for managing/initialisation of the 2nd 64K bank.Not sure about that but what I had in mind is that they had to do it due to a licence topic or copy protection. Will dig the info out somewhere...
Maybe the ROM-Part of Dr.Logo, which was placed in the second 8KB of the Amsdos ROM, was using #C3? But yes, that's not really CP/M(+) related, just another example that #C3 was designed for Rom software.
[this Dr.Logo for CP/M+ was a very strange oddity of Amstrad anyway: including a part of an alternative programming language in ROM, which still required booting another OS from disc + the remaining part of the programming language, and which wasn't used at all by most of the users :) ]
10 out &7f00,&c4
20 poke &4000,4
30 out &7f00,&c5
40 poke &4000,5
50 out &7f00,&c6
60 poke &4000,6
70 out &7f00,&c7
80 poke &4000,7
100 out &7f00,&c0
110 print peek(&4000)
120 out &7f00,&c4
130 print peek(&4000)
140 out &7f00,&c5
150 print peek(&4000)
160 out &7f00,&c6
170 print peek(&4000)
180 out &7f00,&c7
190 print peek(&4000)
200 out &7f00,&c0
Quote from: McArti0 on 12:11, 04 March 24GENIUS! :D;D 8) :laugh:
Quote from: ervin on 11:38, 04 March 24However, I'm wondering if it's possible to use a basic loader, and use OUT commands to change the current banking scheme, and then load a BIN file into the appropriate bank.You can page in RAM bank 4-7 at &4000 and then use a normal load command for binary files with the target address &4000.
Quote from: ervin on 11:38, 04 March 24However, I'm wondering if it's possible to use a basic loader, and use OUT commands to change the current banking scheme, and then load a BIN file into the appropriate bank.That is what I did with Sly Spy allegro : I fill the banks with music files & the player from the basic loader.
1 SYMBOL AFTER 256:OPENOUT"JMB":MEMORY HIMEM-1:CLOSEOUT
10 DATA CD,01,56,CD,6B,54,01,C0,7F,ED,49
20 MODE 1:BORDER 0:INK 0,0:INK 1,26:PEN 1:PAPER 0:CALL &BB00
30 h=HIMEM-1:MEMORY &3FFF:PRINT "LOADING PATCH..."
40 OUT &7F00,&C4
50 REM Setup a dummy interrupt handler in extra-ram, offset 38h
60 POKE &4038,&FB:POKE &4039,&C9
70 REM ORG &0717:jp &00AA
80 POKE &4717,&C3:POKE &4718,&AA:POKE &4719,0
90 REM ORG &0736:call &5601:call &546B:ld bc,&7FC0:out (c),c
100 FOR x%=&4736 TO &4740:READ a$:POKE x%,VAL("&"+a$):NEXT
110 LOAD"PATCH.BIN",&40AA
120 REM Bounce 64K users
130 OUT &7F00,&C0
140 IF PEEK(&4038)=&FB AND PEEK(&4039)=&C9 THEN PRINT"ERROR: 128K OF RAM REQUIRED. ";CHR$(225):END
150 PRINT"LOADING PATCH 2..."
160 LOAD"PATCH2.BIN",&6000
170 REM Load AYC player & music files in extra-ram (4000h to F???h)
180 PRINT"LOADING MUSIC BLOCK 1..."
190 OUT &7F00,&C5
200 LOAD"MUSIC1.BIN",&4000
210 PRINT"LOADING MUSIC BLOCK 2..."
220 OUT &7F00,&C6
230 LOAD"MUSIC2.BIN",&4000
240 PRINT"LOADING MUSIC BLOCK 3..."
250 OUT &7F00,&C7
260 LOAD"MUSIC3.BIN",&4000
270 REM Run original loader from default RAM banks
280 PRINT "RUNNING SLY SPY (allegro)... "
290 OUT &7F00,&C0
300 MEMORY h:RUN"CNG.BAS"