Skip to content

Instantly share code, notes, and snippets.

@ao-kenji
Last active August 19, 2016 11:18
Show Gist options
  • Select an option

  • Save ao-kenji/8bd1a2366aff9d3729c450e375eb5f2d to your computer and use it in GitHub Desktop.

Select an option

Save ao-kenji/8bd1a2366aff9d3729c450e375eb5f2d to your computer and use it in GitHub Desktop.
xp test code embedded in OpenBSD/luna88k's bootloader, diff to tsutsui's https://gist.github.com/tsutsui/fbe476093483ceacd79f62a3db8cebf4
--- xp.c.luna68k Thu Aug 18 22:01:49 2016
+++ xp.c Thu Aug 18 21:59:35 2016
@@ -29,7 +29,7 @@
#include "samachdep.h"
#include "status.h"
-#include "xp-psg-data.c"
+#include "xp-data.c"
#define XP_SHM_ADDRESS 0x71000000
#define XP_DEBUG_OFFSET 0x00F0
@@ -48,10 +48,10 @@
#define XP_DATA_OFFSET 0x1000
#define PIO_ADDRESS 0x49000000
-#define PORT_A 0
-#define PORT_B 1
-#define PORT_C 2
-#define CTRL 3
+#define PORT_A (0 * 4)
+#define PORT_B (1 * 4)
+#define PORT_C (2 * 4)
+#define CTRL (3 * 4)
static uint8_t put_pio0c(uint8_t, uint8_t);
@@ -96,7 +96,7 @@
if (!strcmp(argv[1], "init")) {
printf("Assert reset to XP\n");
pio0c = put_pio0c(XP_RESET, ON);
- printf("PIO 0 PortC = %02x\n", pio0c);
+ printf("PIO 0 PortC = 0x%x\n", pio0c);
DELAY(1000);
printf("Loading XP program into 3 port ram at %p\n", xpshm);
for (i = 0; i < sizeof bindata; i++) {
@@ -105,7 +105,7 @@
printf("Negate reset to XP\n");
DELAY(1000);
pio0c = put_pio0c(XP_RESET, OFF);
- printf("PIO 0 PortC = %02x\n", pio0c);
+ printf("PIO 0 PortC = 0x%x\n", pio0c);
printf("Done\n");
} else if (!strcmp(argv[1], "load")) {
const char *fname = argv[2];
@@ -145,8 +145,8 @@
} else if (!strcmp(argv[1], "dump")) {
for (i = 0; i < sizeof bindata; i++) {
if (i % 16 == 0)
- printf("%08x: ", XP_SHM_ADDRESS + i);
- printf("%02x ", xpshm[i]);
+ printf("%x: ", XP_SHM_ADDRESS + i);
+ printf("%x ", xpshm[i]);
if (i % 16 == 16 - 1)
printf("\n");
if (i % 0x100 == 0x100 - 1) {
@@ -165,18 +165,18 @@
fout = xpshm[XP_FOUT_OFFSET];
stat = xpshm[XP_STAT_OFFSET];
loop = xpshm[XP_LOOP_OFFSET];
- printf("XP cmd = 0x%02x, fout = 0x%02x,"
- " stat = 0x%02x, loop = 0x%02x\n",
+ printf("XP cmd = 0x%x, fout = 0x%x,"
+ " stat = 0x%x, loop = 0x%x\n",
cmd, fout, stat, loop);
dinfo = xpshm[XP_DEBUG_OFFSET + 0];
dinfo |= xpshm[XP_DEBUG_OFFSET + 1] << 8;
- printf("XP main step: %5d (0x%04x)\n", dinfo, dinfo);
+ printf("XP main step: %d (0x%x)\n", dinfo, dinfo);
dinfo = xpshm[XP_DEBUG_OFFSET + 2];
dinfo |= xpshm[XP_DEBUG_OFFSET + 3] << 8;
- printf("XP main count: %5d (0x%04x)\n", dinfo, dinfo);
+ printf("XP main count: %d (0x%x)\n", dinfo, dinfo);
dinfo = xpshm[XP_DEBUG_OFFSET + 4];
dinfo |= xpshm[XP_DEBUG_OFFSET + 5] << 8;
- printf("XP timer count: %5d (0x%04x)\n", dinfo, dinfo);
+ printf("XP timer count: %d (0x%x)\n", dinfo, dinfo);
} else {
printf("Unknown subcommand: %s\n", argv[1]);
return ST_ERROR;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment