Index: CPC stuff/gordon/manager/Makefile
===================================================================
--- CPC stuff/gordon/manager/Makefile	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
+++ CPC stuff/gordon/manager/Makefile	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
@@ -0,0 +1,13 @@
+# Requires uppercase because CPCFS is buggy
+NAME:=GORDON
+
+# Set disk contents
+$(NAME).dsk:: $(NAME).BIN
+
+# List the sourcefiles for your main code. This is currently statically linked
+# at &300 and (hopefully) loaded there by the loader code.
+# TODO use a target variable for the address, and get it from VASM/VLINK somehow
+$(NAME).BIN:: gordon.o
+$(NAME).BIN: START = 0x2000
+
+include cpc.mk
Index: CPC stuff/gordon/manager/cpc.mk
===================================================================
--- CPC stuff/gordon/manager/cpc.mk	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
+++ CPC stuff/gordon/manager/cpc.mk	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
@@ -0,0 +1,55 @@
+# Amstrad CPC generic makefile rules
+# Copyright 2011-2012, Shinra Team
+# Distributed under the terms of the MIT Licence
+# 
+# Targets the vasm compiler (z80,oldstyle) and vlink tool.
+# Also uses cpcfs, png2crtc, exomizer, caprice
+#
+# Just make a dsk file depend on some BIN files, and these depend on some .o files.
+# Don't forget to set START for each BIN file (used as the start address for linking
+# and put in the AMSDOS header)
+
+.DEFAULT_GOAL := $(NAME).dsk
+
+# Nice header for doing something
+BECHO = @echo -e "\x1B[7m\t$(1)\t\x1B[0m"
+
+# Build the DSK-File (main rule)
+%.dsk:
+	$(call BECHO, "Putting files in DSK...")
+	cpcfs $@ f
+	for i in $^;do cpcfs $@ p $$i;done;
+
+# Run the emulator
+emu: $(NAME).dsk
+	$(call BECHO,"Running caprice...")
+	caprice -a $< &
+
+# Link the sources ($^ means "all dependencies", so all of them should be .o 
+# files - which is good, since anything else should be incbined somewhere)
+%.BIN:
+	$(call BECHO,"Linking $@")
+	vlink -Ttext $(START) -Tlink.ld -b amsdos -o $@ $^
+	
+#-Ttext $(START)
+
+# Assemble the sources
+%.o: %.z80
+	$(call BECHO,"Assembling $<...")
+	vasmz80_oldstyle -Fvobj -o $@ $<
+
+# Crunch a screen
+%.exo: %.scr
+	$(call BECHO,"Crunching $<...")
+	exoraw -o $@ $<
+
+# convert png to cpc screen format
+# SCREENMODE can force the screenmode, otherwise it's guessed from the png 
+# bitdepth
+%.scr: %.png
+	$(call BECHO,"Converting $<...")
+	png2crtc $< $@ 7 $(SCREENMODE)
+
+clean:
+	$(call BECHO,"Cleaning...")
+	rm *.exo *.BIN *.dsk *.o
Index: CPC stuff/gordon/manager/flashrom.s
===================================================================
--- CPC stuff/gordon/manager/flashrom.s	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
+++ CPC stuff/gordon/manager/flashrom.s	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
@@ -0,0 +1,173 @@
+; ---------------------------------------------------------------------------
+; Mini-Rom Install for MegaFlash (c) SyX 2011
+;
+; Based in the example sourcecode post in CPCWiki by
+; (C) Dr. Stefan W. Stumpferl
+; (Cr) TFM of FutureSoft 2011
+;
+; This routine can be used for foreign programs, 
+; but this remark must be left as it is.
+; ---------------------------------------------------------------------------
+NUM_ROM EQU 6 ; 16
+
+    include 'firmware.i'
+    include 'hardware.i'
+
+    ORG  $4000
+inicio
+    ; 1 .- Indicamos que se ponga el MegaFlash en modo de escritura y se pulse una tecla
+    ; Ponemos el border Negro
+    LD   BC,0 * 256 + 0
+    CALL SCR_SET_BORDER
+
+    CALL espera_tecla
+
+    ; Ponemos el border Blanco
+    LD   BC,16 * 256 + 16
+    CALL SCR_SET_BORDER
+
+    ; Esperamos al refresco
+    CALL MC_WAIT_FLYBACK
+    HALT 
+
+    ; 2.- Escribimos la ROM en el MegaFlash
+    LD   A,NUM_ROM          ; Nº de ROM en el MegaFlash
+    LD   HL,rom_data        ; Puntero a los datos de la ROM
+    CALL write_rom
+
+    ; 3.- Indicamos que la ROM fue escrita, la comprobamos e indicamos el resultado de la comprobación
+    ; Ponemos el border Blanco
+    LD   BC,26 * 256 + 26
+    CALL SCR_SET_BORDER
+
+    CALL espera_tecla
+
+    ; 4.- Indicamos que se ponga el MegaFlash en modo lectura y esperamos a una tecla antes de reiniciar.
+    LD   A,NUM_ROM          ; Nº de ROM en el MegaFlash
+    LD   HL,rom_data        ; Puntero a los datos de la ROM
+    CALL test_rom
+    JR   C,.error_test
+    ; Ponemos el border Verde
+    LD   BC,18 * 256 + 18
+    CALL SCR_SET_BORDER
+    JR   .exit
+.error_test
+    ; Ponemos el border Rojo
+    LD   BC,6 * 256 + 6
+    CALL SCR_SET_BORDER
+.exit
+    CALL espera_tecla
+
+    ; Despaginamos el MegaFlash
+    CALL $0000
+
+; ---------------------------------------------------------------------------
+; Copiamos una ROM de 16 KBs al MegaFlash
+;
+; Entradas:
+;     A : Nº de ROM (0 - 31)
+;    HL : Puntero a los 16 KBs de la ROM
+; ---------------------------------------------------------------------------
+write_rom
+    DI                          ; Desactivamos las interrupciones
+
+    LD   B,>UPPER_ROM_SELECT
+    OUT  (C),A                  ; Seleccionamos la ROM del MegaFlash que vamos a escribir
+
+    LD   BC,GATE_ARRAY + MODE_Y_ROM + LOWER_OFF + UPPER_ON + MODE_2
+    OUT  (C),C
+
+    LD   DE,RAM_P3              ; Dirección de destino es $C000
+
+.copy_256_bytes
+    LD   BC,$0100
+    LDIR                        ; Copiamos 256 bytes de RAM al MegaFlash (buffer MegaFlash)
+
+    LD   C,$20                  ; El MegaFlash necesita tiempo para borrar y escribir
+.espera_32_ms                   ; >>> 32 * 256 Loops * 4 ys = 32 ms
+    DJNZ .espera_32_ms
+    DEC  C
+    JR   NZ,.espera_32_ms
+
+    ; Comprobamos que se hayan copiado los 16KBs de la ROM
+    LD   A,D
+    OR   E
+    JR   NZ,.copy_256_bytes      ; En caso contrario copiamos el siguiente bloque de 256 bytes
+
+    LD   BC,UPPER_ROM_SELECT    ; Seleccionamos la ROM del Basic
+    OUT  (C),C
+
+    EI                          ; Reactivamos las interrupciones
+
+    RET
+
+; ---------------------------------------------------------------------------
+; Comprobamos que la ROM se escribió correctamente en el MegaFlash
+;
+; Entradas:
+;     A : Nº de ROM (0 - 31)
+;    HL : Puntero a los 16 KBs de la ROM
+; Salidas:
+;    Carry flag activo en caso de Error
+; ---------------------------------------------------------------------------
+test_rom
+    DI                          ; Desactivamos las interrupciones
+
+    LD   B,>UPPER_ROM_SELECT
+    OUT  (C),A                  ; Seleccionamos la ROM del MegaFlash que vamos a comprobar
+
+    LD   BC,GATE_ARRAY + MODE_Y_ROM + LOWER_OFF + UPPER_ON + MODE_2
+    OUT  (C),C
+
+    LD   DE,RAM_P3              ; Dirección de origen de la ROM
+.bucle_de_comprobacion
+    LD   A,(DE)
+    CP   (HL)
+    JR   NZ,.error_comprobacion
+    INC  HL
+    INC  DE
+    LD   A,D
+    OR   E
+    JR   NZ,.bucle_de_comprobacion
+
+    LD   BC,UPPER_ROM_SELECT    ; Seleccionamos la ROM del Basic
+    OUT  (C),C
+    EI                          ; Reactivamos las interrupciones
+
+    XOR  A
+    RET
+
+.error_comprobacion
+    LD   BC,UPPER_ROM_SELECT    ; Seleccionamos la ROM del Basic
+    OUT  (C),C
+    EI                          ; Reactivamos las interrupciones
+
+    SCF
+    RET
+
+; ---------------------------------------------------------------------------
+espera_tecla
+    ; Reiniciamos el Key Manager
+    CALL KM_RESET
+
+    ; Esperamos a que no haya ninguna tecla pulsada
+.bucle_espera_tecla
+    CALL KM_READ_KEY
+    JR   C,.bucle_espera_tecla
+
+    ; Esperamos al refresco
+    CALL MC_WAIT_FLYBACK
+    HALT 
+
+    ; Esperamos a que se pulse una tecla
+    CALL KM_WAIT_KEY
+
+    RET
+
+; ---------------------------------------------------------------------------
+rom_data
+;    incbin 'qcmd.rom'
+    incbin 'parados.rom'
+
+; ---------------------------------------------------------------------------
+    END
Index: CPC stuff/gordon/manager/gordon.z80
===================================================================
--- CPC stuff/gordon/manager/gordon.z80	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
+++ CPC stuff/gordon/manager/gordon.z80	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
@@ -0,0 +1,92 @@
+; FLASH GORDON driver
+; Copyright 2012, Adrien Destugues <pulkomandy@gmail.com>
+; This program is distributed under the terms of the MIT licence
+
+; Start here.
+	DI
+
+; Move the screen to $8000 or $0000 so we can display things to the user, while
+; C000 will write to the ROM and 4000 will hold the data to write... That could
+; get a bit messy so maybe we will need to use the screen at 4000 as a buffer
+; for the ROM data as well. Or just use a bank for that ?
+
+; Map the ROM in
+; TODO
+
+; ask the user to enable writing
+; TODO
+
+; Check if we can read the ROM type
+	LD A, 0x90
+	CALL send_command
+
+	LD HL, 0xC000
+
+	LD A,(HL)
+	CALL printhex
+	INC L
+	LD A,(HL)
+	CALL printhex
+
+	; We should get 0x8F 87
+	; TODO check that before continuing with writing the data
+	JR $
+
+	; Now reuse and adapt the code from OUL guys !
+
+; That's all folks !
+	RET
+
+; Helper routines -----------------------------------------------------
+
+; Send a command to the ROM. The available commands are :
+ERASE		equ	0x80
+IDENTIFY	equ	0x90
+BYTEPROG	equ 0xA0
+RESET		equ	0xF0
+
+; Input: Commend to send in A register
+send_command:
+	; Select ROM 1
+	LD BC,0xDF01
+	LD HL,0xD555
+	LD DE,0xEAAA
+
+	; Select ROM 1 and write 0xAA to address 0xD555
+	OUT (C),C
+	LD (HL),E
+
+	; Select ROM 2 and write 0x55 to address 0xEAAA
+	INC C
+	OUT (C),C
+	EX DE,HL
+	LD (HL), E
+
+	; Select ROM 1 again and write the command to address 0xEAAA
+	DEC C
+	OUT (C),C
+	EX DE,HL
+	LD (HL), A
+
+	RET
+
+
+; Print value of A, as 2 hex digits
+printhex
+	PUSH	AF
+	RRA	
+	RRA	
+	RRA	
+	RRA		;divise A par 8 
+	CALL	PRNHEX1	;affiche le premier morceau
+	POP	AF	;r{cup la valeur originale pour la suit
+PRNHEX1			;affiche la valeur de A sur 1 chiffre
+;affiche A sur 1 chiffre en Hexa
+	AND	0xF	;ne prend que les unit{s
+	OR	A
+	DAA		;convertit en d{cimal  
+	ADD	A,0xF0	;ajoute 240
+	ADC	A,0x40	;ajoute 64+le carry (si >15)
+;on a le code ascii du chiffre @ afficher
+	JP	0xBB5A	;call-ret
+;
Index: CPC stuff/gordon/manager/link.ld
===================================================================
--- CPC stuff/gordon/manager/link.ld	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
+++ CPC stuff/gordon/manager/link.ld	(revision 7dcccbceeddb3c400d5639530b7f5bf662cee282)
@@ -0,0 +1,5 @@
+SECTIONS {
+	.text: { *(.text) }
+	. = MAX(.,0x3FFC);
+	.romcalls: { *(.romcalls) }
+}
