Me he vuelto a poner con esto hace unos días. Ya por probar, probé un par de chips que me habían recomendado (el demultiplexor), y también probé a cambiar las PIAs de sitio. Nada.
Entonces me puse a leer el libro de
Inside the Dragon (buenísimo por cierto) y describen en detalle el proceso de arranque:
9.1 POWER-UP/RESET ACTIONS
When you switch on your machine a RESET interrupt occurs and this causes a transfer to an initialisation routine in ROM at address B3B4. The first thing that this routine does is to configure the SAM chip as, until this is done, RAM cannot be used. Then the PIAs are configured to their default settings which, in turn, sets up the VDG and I/O devices. The hardware initialisation routine may also be accessed via the direct jump table and a jump to this routine is stored at location 8000. The routine expects the return address to be in register Y as RAM is not available.
Once the hardware is initialised, a software initialisation stage is entered which first sets up a temporary stack for subroutine calling. The next step is to find out whether this is a 'cold-start' or a 'warm-start' reset and this is determined by the contents of the reset flag at address 71 and the secondary reset vector at addresses 72:73. If the reset flag is $55 and the secondary reset vector points to a NOP instruction, a warm-start sequence is initiated otherwise a cold-start takes place.
The software initialisation routine may be accessed via the jump table (8003) and has neither input nor output parameters.
224
9.1.1 Cold-start initialisation
When first switched on, the machine's random access memory contains random bit patterns as the contents of RAM are lost when the power is switched off. Therefore, the first action of the cold-start routine is to clear RAM to zeros so that system variables, etc. have a default value of zero.
The next step is to clear the text screen and this is followed by a RAM-sizing operation which detects the top of the useable RAM on the machine. The size of RAM can be determined by altering consecutive memory locations in turn until an unalterable location is detected. This is the start of ROM so the last RAM address is the address which immediately precedes this.
The final step in the software initialisation is to set up BASIC'S system variables and these are initialised by copying their values from tables in ROM.
When software initialisation is complete, the reset service routine looks for the occurrence of a disk controller cartridge by checking if the characters 'DK' occupy addresses C000:C001. If a controller is present, the disk controller is initialised by jumping to an initialisation routine at address C002.
If there is no disk controller, IRQ and FIRQ interrupts are enabled by clearing the appropriate bits in the condition code register. This allows an auto- starting ROM cartridge to interrupt on FIRQ thereby transferring control to the cartridge software. If no ROM cartridge is present, the secondary reset vector is set to point at the warm-start routine and the reset flag set to $55.
Finally, the BASIC system is initiated and the system is ready for use.
Eso me dio muchas ideas y me ayudó a descartar ciertas cosas. Por ejemplo las ideas de que podía estar colgado esperando la inicialicación de la PIAs no puede ser, porque en mi caso la pantalla se borró con el color correcto, y eso pasa por ahí por el medio.
Y con eso, me cogí la ROM,
un buen libro de ensamblador 6809,
un desensamblador, y
el mapa de la ROM, y me puse a estudiar.
Lo primero que hice fue intentar seguir el proceso de inicialización, y en particular buscar donde se borra la pantalla. Una vez que lo encontré, cambié el código para que rellenase la pantalla con un valor diferente, o solo hiciese al mitad de la pantalla. Lo grabé en una EPROM, lo probé en el Dragon, y todo bien. Hacía lo que tenía que hacer.
A partir de ahí fui modificando el código de la ROM para ver dónde se quedaba colgado. Inicialización de variables, copia de trozos de la ROM a la RAM, escribir el mensaje de inicio... y ahí es donde empiezan las cosas raras. Unas veces llegaba hasta el código que había cambiado allí, y otras veces no. Y de repente no llegaba ni hasta varias subrutinas anteriores. Por lo visto era un problema que iba cambiando, no era siempre igual! Eso huele a problemas de reloj, o a memorias con problemas de timings específicos.
Las memorias ya las había comprobado una a una. Las había sacado, puesto en un CPC, y comprobado que funcionaban bien con el programa de probar memorias. Pero claro, una cosa es que pasen esas pruebas, y otra que funcionen exactamente como tienen que funcionar con los tiempos exactos. O sea que por si acaso las quito todas, pongo otras nuevas y... funciona!
- 2019-06-12 19.48.16.jpg (59.92 KiB) Visto 3754 veces
O sea, llevo casi un año matándome a buscar por donde anda el problema, y eran las memorias que estaban "flojas". Argghhhh.....!!!!!
Para celebrarlo, por supuesto, este fue el primer programa que probé
- 2019-06-12 20.03.31.jpg (65.29 KiB) Visto 3754 veces
Por cierto, el modo de alta resolución se ve más bien mal en la tele. De eso que te saca colores casi sin querer y que encima se mueven un poco y marean. ¿Eso es normal al ser el modo PAL? Una pena. Los programas en resolución menor se ven mucho mejor.
- 2019-06-12 20.01.41.jpg (65.51 KiB) Visto 3754 veces
Pues nada, ahora estoy contentísimo. Es que llevaba más de un año detrás de esta avería! Ahora a disfrutarlo y sacarle partido.