dragon-nx32: Update XRoar patch for 0.33.2 release
authorTormod Volden <debian.tormod@gmail.com>
Thu, 4 Jun 2015 11:08:15 +0000 (13:08 +0200)
committerAlan Cox <alan@linux.intel.com>
Thu, 4 Jun 2015 11:59:12 +0000 (12:59 +0100)
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Kernel/platform-dragon-nx32/0001-XRoar-emulate-nx32.patch
Kernel/platform-dragon-nx32/README

index a56dc5e..e59c2c9 100644 (file)
@@ -1,10 +1,10 @@
-From ec8a5f08542ab23bb11a47f42423779244fd8072 Mon Sep 17 00:00:00 2001
+From a62ae62d94dd5d1e015fc6acd978b2c24d42d442 Mon Sep 17 00:00:00 2001
 From: Tormod Volden <debian.tormod@gmail.com>
 Date: Sat, 10 Jan 2015 12:40:36 +0100
-Subject: [PATCH] XRoar: Emulate Tormod's memory cartridge on Dragon 32
+Subject: [PATCH] XRoar: Emulate Tormod's nx32 memory cartridge for Dragon
 
 * This patch is for the XRoar emulator at http://www.6809.org.uk/xroar/ *
-* It is based off the dev-0.33 branch. *
+* It is based off the 0.33.2 release. *
 
 EXTBANKS is the number of 32KB banks and can be 1, 4 or 16.
 
@@ -19,11 +19,11 @@ Note that the cartridge "firmware" is subject to change.
 
 Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
 ---
- src/machine.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 53 insertions(+)
+ src/machine.c | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
 
 diff --git a/src/machine.c b/src/machine.c
-index 20cbcec..1556ae1 100644
+index 56db6e0..80da258 100644
 --- a/src/machine.c
 +++ b/src/machine.c
 @@ -60,6 +60,13 @@
@@ -33,14 +33,14 @@ index 20cbcec..1556ae1 100644
 +/* number of 32KB banks in external memory cartridge: 1, 4 or 16 */
 +#define EXTBANKS 4
 +static uint8_t extmem[0x8000 * EXTBANKS];
-+static _Bool extmem_map;
-+static _Bool extmem_ty;
-+static uint8_t extmem_bank;
++static _Bool extmem_map;      /* external memory mapped in or not */
++static _Bool extmem_ty;               /* tracks SAM ty register */
++static uint8_t extmem_bank;   /* which bank */
 +
  unsigned int machine_ram_size = 0x10000;  /* RAM in bytes, up to 64K */
  uint8_t machine_ram[0x10000];
  static uint8_t *machine_rom;
-@@ -938,6 +945,8 @@ void machine_reset(_Bool hard) {
+@@ -943,6 +950,8 @@ void machine_reset(_Bool hard) {
        }
        if (hard) {
                initialise_ram();
@@ -49,78 +49,44 @@ index 20cbcec..1556ae1 100644
        }
        mc6821_reset(PIA0);
        mc6821_reset(PIA1);
-@@ -1087,6 +1096,11 @@ static uint8_t read_cycle(void *m, uint16_t A) {
-        * produce a different "null" result on his 16K CoCo */
-       if (is_ram_access)
-               read_D = 0xff;
-+      /* external memory cartridge */
-+      if (A < 0xff00 && (A > 0xbfff || (!extmem_ty && extmem_map && A > 0x7fff))) {
-+              read_D = extmem[0x8000 * extmem_bank + (A & 0x7fff)];
-+              S = 8; /* decoder disabled */
-+      }
-       switch (S) {
-               case 0:
-                       if (Z < machine_ram_size)
-@@ -1170,6 +1184,23 @@ static void write_cycle(void *m, uint16_t A, uint8_t D) {
-               update_vdg_mode();
-       }
-       _Bool is_ram_access = do_cpu_cycle(A, 0, &S, &Z);
-+      /* external memory cartridge */
-+      if ((A & ~1) == 0xFFDE) {
-+              extmem_ty = A & 1;
-+              LOG_PRINT("Switching to SAM map type %d\n", extmem_ty);
-+      }
-+      if ((A & ~1) == 0xFFBE) {
-+              extmem_map = A & 1;
-+              extmem_bank = D & (EXTBANKS - 1);
-+              if (extmem_map)
-+                      LOG_DEBUG(3, "Switching to bank %d\n", extmem_bank);
-+              else
-+                      LOG_DEBUG(3, "Switching off bank %d\n", extmem_bank);
-+      }
-+      if (A < 0xff00 && (A > 0xbfff || (!extmem_ty && extmem_map && A > 0x7fff))) {
-+              extmem[0x8000 * extmem_bank + (A & 0x7fff)] = D;
-+              S = 8; /* decoder disabled */
-+      }
-       if ((S & 4) || unexpanded_dragon32) {
-               switch (S) {
-                       case 1:
-@@ -1256,6 +1287,11 @@ uint8_t machine_read_byte(uint16_t A) {
-       _Bool is_ram_access = debug_cpu_cycle(A, 1, &S, &Z);
-       if (is_ram_access)
-               D = 0xff;
+@@ -1057,6 +1066,13 @@ static uint8_t read_byte(unsigned A) {
+       // produce a different "null" result on his 16K CoCo
+       if (SAM0->RAS)
+               CPU0->D = 0xff;
++
 +      /* external memory cartridge */
 +      if (A < 0xff00 && (A > 0xbfff || (!extmem_ty && extmem_map && A > 0x7fff))) {
-+              D = extmem[0x8000 * extmem_bank + (A & 0x7fff)];
-+              S = 8; /* decoder disabled */
++              CPU0->D = extmem[0x8000 * extmem_bank + (A & 0x7fff)];
++              SAM0->S = 8; /* decoder disabled */
 +      }
-       switch (S) {
-               case 0:
-                       if (Z < machine_ram_size)
-@@ -1321,6 +1357,23 @@ void machine_write_byte(uint16_t A, uint8_t D) {
-               update_vdg_mode();
-       }
-       _Bool is_ram_access = debug_cpu_cycle(A, 0, &S, &Z);
++
+       switch (SAM0->S) {
+       case 0:
+               if (SAM0->RAS) {
+@@ -1120,6 +1136,23 @@ static uint8_t read_byte(unsigned A) {
+ }
+ static uint8_t write_byte(unsigned A) {
++
 +      /* external memory cartridge */
-+      if ((A & ~1) == 0xFFDE) {
++      if ((A & ~1) == 0xffde) {
 +              extmem_ty = A & 1;
 +              LOG_PRINT("Switching to SAM map type %d\n", extmem_ty);
-+      }
-+      if ((A & ~1) == 0xFFBE) {
++      } else if ((A & ~1) == 0xffbe) {
 +              extmem_map = A & 1;
-+              extmem_bank = D & (EXTBANKS - 1);
++              extmem_bank = CPU0->D & (EXTBANKS - 1);
 +              if (extmem_map)
 +                      LOG_DEBUG(3, "Switching to bank %d\n", extmem_bank);
 +              else
 +                      LOG_DEBUG(3, "Switching off bank %d\n", extmem_bank);
++      } else if (A < 0xff00 && (A > 0xbfff || (!extmem_ty && extmem_map && A > 0x7fff))) {
++              extmem[0x8000 * extmem_bank + (A & 0x7fff)] = CPU0->D;
++              SAM0->S = 8; /* decoder disabled */
 +      }
-+      if (A < 0xff00 && (A > 0xbfff || (!extmem_ty && extmem_map && A > 0x7fff))) {
-+              extmem[0x8000 * extmem_bank + (A & 0x7fff)] = D;
-+              S = 8; /* decoder disabled */
-+      }
-       if ((S & 4) || unexpanded_dragon32) {
-               switch (S) {
-                       case 1:
++
+       if ((SAM0->S & 4) || unexpanded_dragon32) {
+               switch (SAM0->S) {
+               case 1:
 -- 
-1.7.9.5
+1.9.1
 
index 5c74eac..009b207 100644 (file)
@@ -25,9 +25,6 @@ Emulating in XRoar
 XRoar can be patched with the included 0001-XRoar-emulate-nx32.patch
 to emulate this memory cartridge.
 
-*NOTE*: This patch works with 0.32, but not the latest 0.33 release of
-XRoar.
-
 Using DriveWire
 ===============