Bank0 equ &C0
Bank1 equ &C4
Bank2 equ &C5
Bank3 equ &C6
Bank4 equ &C7
Bank5 equ &CC
Bank6 equ &CD
Bank7 equ &CE
Bank8 equ &CF
BankBase equ &4000



BankSwitch_DefaultMem:
	ld a,&C0
BankSwitch_SetCurrent:				; This allows us to remember 'current' bank

	LD B,&7F ;Gate array port
	ld (BankSwitch_CurrentB_Plus2-2),a
	OUT (C),A ;Send it
	ret

BankSwitch_BankCopy:
	push bc
		call BankSwitch_Set
	pop bc
	ldir

BankSwitch_Reset:
	ld a,(BankSwitch_CurrentB_Plus2-2)
BankSwitch_Set:

	LD B,&7F ;Gate array port

	OUT (C),A ;Send it
	ret



	db &C0,00 ;<--SM ***
BankSwitch_CurrentB_Plus2:


DoRestoreJumpBlock:
	rst 8
	defw &08bd ;<--SM ***
FirmJumpLoc_Plus2:                  ;initialise firmware jumpblock entries
DoRestoreJumpBlockEnd:
DoRestoreLowJumpBlock:
	exx
	ld bc,&7f00+%10001000+1  ;initialise lower rom and select mode
	out (c),c                   ;this routine must be located above &4000
	xor a
	exx
	ex af,af'
	call &0044                  ;initialise lower jumpblock (&0000-&0040)
	;ld bc,&7f00+%10001100+1  ;initialise lower rom and select mode
	;out (c),c                   ;this routine must be located above &4000
	Call &F7D0;DoRestoreJumpBlock
	call &bb00 ; km_initialise          ;initialise keyboard manager
	call &b909 ;kl_l_rom_disable       ;disable lower rom
	ld de,&A500	; first usable byte of memory
	ld hl,&b0ff	; last usable byte of memory
	call &bccb ; KL_ROM_WALK
	;ld c,7	DiskRomNumber_Plus1	; number of AMSDOS ROM
	;call &bcce	; initialise AMSDOS ROM; this also resets drive number to 0 (drive A)
	call &b909 ;kl_l_rom_disable       ;disable lower rom

	ret
DoRestoreLowJumpBlockEnd:            ;and high kernal jumpblock (&b800-&bae4)



Firmware_Restore:	; About that firmware...
	di	
;	call RasterColors_Disable

	;restore colors
;	call RasterColors_DefaultSafe

	;reset our raster events
;	ld hl,(RasterColors_PerFrameCall_Plus2-2)
;	ld (RasterColors_PerFrameCallRestore_Plus2-2),hl
	;ld hl,&C9FB
	;ld (&FFFE),hl
	;ld hl,&FFFE
	;ld (RasterColors_PerFrameCall_Plus2-2),hl
	ld hl,&A500
	ld de,&A501
	ld bc,&BFD0 -&A501
	xor a
	ld (hl),a
	ldir

	ld hl,DoRestoreLowJumpBlock
	ld de,&FFD0
	ld bc,DoRestoreLowJumpBlockEnd-DoRestoreLowJumpBlock
	ldir
	ld hl,DoRestoreJumpBlock
	ld de,&F7D0
	ld bc,DoRestoreJumpBlockEnd-DoRestoreJumpBlock
	ldir
	call &FFD0


	call &BCB6 ;sound hold
	ei
	;restore Disk operating system Vars here - Please add your own
	;if you have special requirements



	ld hl,&0000;<--SM ***
ParadosSettings_Plus2:
	ld (&BAFE),hl

	ld a,0;<--SM ***
FirwareRestoreDriveNo_Plus1:
	ld hl,(&be7d)	; get address where current drive number is held
	ld (hl),a	; set drive number to previous value

	ret
	
	
	
CpcPlus_BankEnable:	
	ld bc,&7fb8	;Page in PLUS registers	(alt rambank at &4000-&7FFF)
	out (c),c				
	ret

CpcPlus_BankDisable:
	ld bc,&7fa0	;Page out PLUS registers
	out (c),c
	ret

	
BankSwapper_SetCartBank:
	add 128
	ld b,&DF
	ld c,a
	out (c),c
	
	ld b,&7F
	ld c,%10000101
	out (c),c
	
ret


