Compare commits
8
Commits
fe9c5c4781
...
6e9b727b31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e9b727b31 | ||
|
|
7ab5bd28bf | ||
|
|
41cd7bc089 | ||
|
|
31b7403252 | ||
|
|
29ade46a0a | ||
|
|
534ce852f4 | ||
|
|
4ed3b72995 | ||
|
|
8598eab087 |
+2
-2
@@ -234,7 +234,7 @@ static int cpuOnExecute(VB *sim) {
|
|||||||
#define VB_ON_READ VB_DIRECT_READ
|
#define VB_ON_READ VB_DIRECT_READ
|
||||||
#endif
|
#endif
|
||||||
static int cpuRead(VB *sim, uint32_t address, int type, int32_t *value) {
|
static int cpuRead(VB *sim, uint32_t address, int type, int32_t *value) {
|
||||||
uint32_t cycles = 4; /* TODO: Research this */
|
uint32_t cycles = 0; /* TODO: Research this */
|
||||||
|
|
||||||
/* Retrieve the value from the simulation state directly */
|
/* Retrieve the value from the simulation state directly */
|
||||||
busRead(sim, address, type, value);
|
busRead(sim, address, type, value);
|
||||||
@@ -289,7 +289,7 @@ static int cpuReadFetch(VB *sim, int fetch, uint32_t address, int32_t *value) {
|
|||||||
#endif
|
#endif
|
||||||
static int cpuWrite(VB *sim, uint32_t address, int type, int32_t value) {
|
static int cpuWrite(VB *sim, uint32_t address, int type, int32_t value) {
|
||||||
int cancel = 0;
|
int cancel = 0;
|
||||||
uint32_t cycles = 3; /* TODO: Research this */
|
uint32_t cycles = 0; /* TODO: Research this */
|
||||||
|
|
||||||
/* Reset pseudo-halt */
|
/* Reset pseudo-halt */
|
||||||
if (sim->ph.enabled)
|
if (sim->ph.enabled)
|
||||||
|
|||||||
@@ -900,7 +900,7 @@ VBAPI vbOnWrite vbSetWriteCallback(VB *sim, vbOnWrite callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the size of a simulation instance */
|
/* Determine the size of a simulation instance */
|
||||||
VBAPI size_t vbSizeOf() {
|
VBAPI size_t vbSizeOf(void) {
|
||||||
return sizeof (VB);
|
return sizeof (VB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ VBAPI vbOnSamples vbSetSamplesCallback (VB *sim, vbOnSamples callback);
|
|||||||
VBAPI uint32_t vbSetSystemRegister (VB *sim, unsigned index, uint32_t value);
|
VBAPI uint32_t vbSetSystemRegister (VB *sim, unsigned index, uint32_t value);
|
||||||
VBAPI void* vbSetUserData (VB *sim, void *tag);
|
VBAPI void* vbSetUserData (VB *sim, void *tag);
|
||||||
VBAPI vbOnWrite vbSetWriteCallback (VB *sim, vbOnWrite callback);
|
VBAPI vbOnWrite vbSetWriteCallback (VB *sim, vbOnWrite callback);
|
||||||
VBAPI size_t vbSizeOf ();
|
VBAPI size_t vbSizeOf (void);
|
||||||
VBAPI int32_t vbWrite (VB *sim, uint32_t address, int type, int32_t value);
|
VBAPI int32_t vbWrite (VB *sim, uint32_t address, int type, int32_t value);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+29
-22
@@ -41,16 +41,17 @@ static const uint8_t BG_TEMPLATES[][64] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* 8-bit color magnitude by brightness level */
|
/* 8-bit color magnitude by brightness level */
|
||||||
|
/* Generated as BRIGHT8[n] = round((n / 132) ** 1.6 * 255) */
|
||||||
static const uint8_t BRIGHT8[] = {
|
static const uint8_t BRIGHT8[] = {
|
||||||
0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 28,
|
0, 12, 19, 24, 29, 33, 37, 41, 44, 48, 51, 54, 57, 60, 63, 65,
|
||||||
30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 57, 59,
|
68, 71, 73, 76, 78, 81, 83, 86, 88, 90, 92, 95, 97, 99,101,103,
|
||||||
61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 86, 88, 90,
|
105,107,109,111,113,115,117,119,121,123,125,127,128,130,132,134,
|
||||||
92, 94, 96, 98,100,102,104,106,108,110,112,113,115,117,119,121,
|
136,137,139,141,142,144,146,148,149,151,153,154,156,157,159,161,
|
||||||
123,125,127,129,131,133,135,137,139,141,142,144,146,148,150,152,
|
162,164,165,167,168,170,172,173,175,176,178,179,181,182,184,185,
|
||||||
154,156,158,160,162,164,166,168,170,171,173,175,177,179,181,183,
|
186,188,189,191,192,194,195,197,198,199,201,202,203,205,206,208,
|
||||||
185,187,189,191,193,195,197,198,200,202,204,206,208,210,212,214,
|
209,210,212,213,214,216,217,218,220,221,222,224,225,226,228,229,
|
||||||
216,218,220,222,224,226,227,229,231,233,235,237,239,241,243,245,
|
230,231,233,234,235,236,238,239,240,242,243,244,245,246,248,249,
|
||||||
247,249,251,253,255
|
250,251,253,254,255
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -319,6 +320,7 @@ static void vipWriteWorld(VB *sim, uint32_t offset, int type, int32_t value) {
|
|||||||
uint32_t base; /* Base BG map index */
|
uint32_t base; /* Base BG map index */
|
||||||
uint8_t *bg; /* Background template */
|
uint8_t *bg; /* Background template */
|
||||||
uint32_t count; /* Number of BG maps in background */
|
uint32_t count; /* Number of BG maps in background */
|
||||||
|
int32_t width; /* Computed affine width */
|
||||||
World *world; /* World state */
|
World *world; /* World state */
|
||||||
uint32_t z; /* Iterator */
|
uint32_t z; /* Iterator */
|
||||||
|
|
||||||
@@ -380,10 +382,10 @@ static void vipWriteWorld(VB *sim, uint32_t offset, int type, int32_t value) {
|
|||||||
case 5: world->mp = SignExtend(value, 15); break;
|
case 5: world->mp = SignExtend(value, 15); break;
|
||||||
case 6: world->my = SignExtend(value, 13); break;
|
case 6: world->my = SignExtend(value, 13); break;
|
||||||
case 7: /* W */
|
case 7: /* W */
|
||||||
value = SignExtend(value, 13) + 1;
|
width = SignExtend(value, 13) + 1;
|
||||||
world->wNaffine = value < 0 ? 0 : value;
|
world->wNaffine = width < 0 ? 0 : width;
|
||||||
value = SignExtend(value, 10) + 1;
|
width = SignExtend(value, 10) + 1;
|
||||||
world->wAffine = value < 0 ? 0 : value;
|
world->wAffine = width < 0 ? 0 : width;
|
||||||
world->width = world->bgm != 2 ? world->wNaffine : world->wAffine;
|
world->width = world->bgm != 2 ? world->wNaffine : world->wAffine;
|
||||||
break;
|
break;
|
||||||
case 8: /* H */
|
case 8: /* H */
|
||||||
@@ -1004,7 +1006,7 @@ static void vipDrawAffine(VB *sim, World *world) {
|
|||||||
Cell *cell; /* Source cell */
|
Cell *cell; /* Source cell */
|
||||||
uint8_t *col, *row; /* Output pixel */
|
uint8_t *col, *row; /* Output pixel */
|
||||||
uint8_t pixel; /* Character pixel value */
|
uint8_t pixel; /* Character pixel value */
|
||||||
uint8_t *param; /* World parameter memory */
|
uint32_t param; /* World parameter memory */
|
||||||
int32_t px, py; /* Pixel source coordinates */
|
int32_t px, py; /* Pixel source coordinates */
|
||||||
int32_t dx, dy, mp, mx, my; /* Affine parameters */
|
int32_t dx, dy, mp, mx, my; /* Affine parameters */
|
||||||
int32_t wx; /* Base world X coordinate */
|
int32_t wx; /* Base world X coordinate */
|
||||||
@@ -1051,21 +1053,26 @@ static void vipDrawAffine(VB *sim, World *world) {
|
|||||||
wx = x1 - wx;
|
wx = x1 - wx;
|
||||||
|
|
||||||
/* Process all visible rows */
|
/* Process all visible rows */
|
||||||
param = &sim->vip.ram[world->paramBase | (y1 - world->gy) << 4];
|
param = world->paramBase + ((y1 - world->gy) << 4);
|
||||||
row = &sim->vip.shadow[i][x1 * 224 + y1];
|
row = &sim->vip.shadow[i][x1 * 224 + y1];
|
||||||
for (y = y1; y < y2; y++, param += 16, row++) {
|
for (y = y1; y < y2; y++, param += 16, row++) {
|
||||||
|
|
||||||
/* Parse line parameters */
|
/* Parse line parameters */
|
||||||
mx = (int32_t) busReadBuffer(param + 0, VB_S16) << 6;
|
mx = (int32_t) busReadBuffer(&sim->vip.ram[param | 0], VB_S16) << 6;
|
||||||
mp = (int32_t) busReadBuffer(param + 2, VB_S16);
|
mp = (int32_t) busReadBuffer(&sim->vip.ram[param | 2], VB_S16);
|
||||||
my = (int32_t) busReadBuffer(param + 4, VB_S16) << 6;
|
my = (int32_t) busReadBuffer(&sim->vip.ram[param | 4], VB_S16) << 6;
|
||||||
dx = (int32_t) busReadBuffer(param + 6, VB_S16);
|
dx = (int32_t) busReadBuffer(&sim->vip.ram[param | 6], VB_S16);
|
||||||
dy = (int32_t) busReadBuffer(param + 8, VB_S16);
|
dy = (int32_t) busReadBuffer(&sim->vip.ram[param | 8], VB_S16);
|
||||||
|
|
||||||
/* Adjust left-edge parameters */
|
/* Adjust left-edge parameters */
|
||||||
if ((mp < 0) ^ i) {
|
if ((mp < 0) ^ i) {
|
||||||
mx += dx * (wx + mp);
|
if (mp < 0) {
|
||||||
my += dy * (wx + mp);
|
mx += dx * (wx - mp);
|
||||||
|
my += dy * (wx - mp);
|
||||||
|
} else {
|
||||||
|
mx += dx * (wx + mp);
|
||||||
|
my += dy * (wx + mp);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mx += dx * wx;
|
mx += dx * wx;
|
||||||
my += dy * wx;
|
my += dy * wx;
|
||||||
|
|||||||
@@ -548,6 +548,7 @@ static void vsuReset(VB *sim) {
|
|||||||
|
|
||||||
/* Write a typed value to the VSU bus */
|
/* Write a typed value to the VSU bus */
|
||||||
static void vsuWrite(VB*sim,uint32_t address,int type,int32_t value,int debug){
|
static void vsuWrite(VB*sim,uint32_t address,int type,int32_t value,int debug){
|
||||||
|
(void) type;
|
||||||
|
|
||||||
/* Unmapped */
|
/* Unmapped */
|
||||||
if (address & 1)
|
if (address & 1)
|
||||||
|
|||||||
+730
-592
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -257,7 +257,7 @@ static void* isxFrom(uint8_t *bytes, size_t length, size_t *romLength) {
|
|||||||
src < lowMax + 0x1000001 - highMin;
|
src < lowMax + 0x1000001 - highMin;
|
||||||
src <<= 1
|
src <<= 1
|
||||||
);
|
);
|
||||||
rom = VBU_REALLOC(NULL, src);
|
rom = VBU_MEMMGR(NULL, src);
|
||||||
if (rom == NULL)
|
if (rom == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
*romLength = src;
|
*romLength = src;
|
||||||
|
|||||||
+37
-19
@@ -5,28 +5,28 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vbu.h>
|
#include <vbu.h>
|
||||||
|
|
||||||
/* Memory management */
|
|
||||||
#ifndef VBU_REALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#define VBU_REALLOC realloc
|
|
||||||
#else
|
|
||||||
extern void* VBU_REALLOC(void *, size_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************** Library Functions *****************************/
|
/***************************** Library Functions *****************************/
|
||||||
|
|
||||||
/* Sign-extend an integer of variable width */
|
/* Memory manager */
|
||||||
static int32_t SignExtend(int32_t value, int32_t bits) {
|
#ifdef VBU_MEMMGR
|
||||||
#ifndef VB_SIGNED_PROPAGATE
|
extern void* VBU_MEMMGR(void *ptr, size_t size);
|
||||||
value &= ~((uint32_t) 0xFFFFFFFF << bits);
|
#else
|
||||||
bits = (int32_t) 1 << (bits - (int32_t) 1);
|
#include <stdlib.h>
|
||||||
return (value ^ bits) - bits;
|
static void* VBU_MEMMGR(void *ptr, size_t size) {
|
||||||
#else
|
|
||||||
return value << (32 - bits) >> (32 - bits);
|
/* Free a buffer */
|
||||||
#endif
|
if (size == 0) {
|
||||||
|
if (ptr != NULL)
|
||||||
|
free(ptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create or resize a buffer */
|
||||||
|
return realloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -46,14 +46,21 @@ VBUAPI int vbuCodeSize(VB *sim, uint32_t address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize disassembler options with default settings */
|
/* Initialize disassembler options with default settings */
|
||||||
VBUAPI VBU_DasmConfig* vbuDasmInit(VBU_DasmConfig *config) {
|
VBUAPI VBU_DasmConfig* vbuDasmDefaults(VBU_DasmConfig *config) {
|
||||||
|
|
||||||
|
/* Error checking */
|
||||||
|
if (config == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Supply default configuration */
|
||||||
config->bcondNotation = VBU_JOINED;
|
config->bcondNotation = VBU_JOINED;
|
||||||
|
config->branchNotation = VBU_ABSOLUTE;
|
||||||
config->conditionCase = VBU_LOWER;
|
config->conditionCase = VBU_LOWER;
|
||||||
config->conditionCL = VBU_L;
|
config->conditionCL = VBU_L;
|
||||||
config->conditionEZ = VBU_Z;
|
config->conditionEZ = VBU_Z;
|
||||||
config->conditionNotation = VBU_NAMES;
|
config->conditionNotation = VBU_NAMES;
|
||||||
config->hexCase = VBU_UPPER;
|
config->hexCase = VBU_UPPER;
|
||||||
config->hexNotation = VBU_0X;
|
config->hexNotation = VBU_PREFIX_0X;
|
||||||
config->immediateNotation = VBU_NONE;
|
config->immediateNotation = VBU_NONE;
|
||||||
config->memoryNotation = VBU_OUTSIDE;
|
config->memoryNotation = VBU_OUTSIDE;
|
||||||
config->mnemonicCase = VBU_UPPER;
|
config->mnemonicCase = VBU_UPPER;
|
||||||
@@ -69,6 +76,17 @@ VBUAPI VBU_DasmConfig* vbuDasmInit(VBU_DasmConfig *config) {
|
|||||||
/* Disassemble from a simulation */
|
/* Disassemble from a simulation */
|
||||||
VBUAPI VBU_DasmLine* vbuDisassemble(VB *sim, uint32_t address,
|
VBUAPI VBU_DasmLine* vbuDisassemble(VB *sim, uint32_t address,
|
||||||
VBU_DasmConfig *config, unsigned length, int line) {
|
VBU_DasmConfig *config, unsigned length, int line) {
|
||||||
|
VBU_DasmConfig defs; /* Default settings */
|
||||||
|
|
||||||
|
/* Error checking */
|
||||||
|
if (sim == NULL || length == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Supply default configuration */
|
||||||
|
if (config == NULL)
|
||||||
|
config = vbuDasmDefaults(&defs);
|
||||||
|
|
||||||
|
/* Disassemble instructions */
|
||||||
return dasmDisassemble(sim, address, config, length, line);
|
return dasmDisassemble(sim, address, config, length, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+29
-26
@@ -17,25 +17,27 @@ extern "C" {
|
|||||||
/********************************* Constants *********************************/
|
/********************************* Constants *********************************/
|
||||||
|
|
||||||
/* Disassembler options */
|
/* Disassembler options */
|
||||||
#define VBU_0X 0
|
#define VBU_ABSOLUTE 0
|
||||||
#define VBU_C 1
|
#define VBU_C 1
|
||||||
#define VBU_DEST_FIRST 1
|
#define VBU_DEST_FIRST 1
|
||||||
#define VBU_DEST_LAST 0
|
#define VBU_DEST_LAST 0
|
||||||
#define VBU_DOLLAR 1
|
#define VBU_E 0
|
||||||
#define VBU_E 0
|
#define VBU_INSIDE 1
|
||||||
#define VBU_H 2
|
#define VBU_JOINED 0
|
||||||
#define VBU_INSIDE 1
|
#define VBU_L 0
|
||||||
#define VBU_JOINED 0
|
#define VBU_LOWER 1
|
||||||
#define VBU_L 0
|
#define VBU_NAMES 1
|
||||||
#define VBU_LOWER 1
|
#define VBU_NONE 0
|
||||||
#define VBU_NAMES 1
|
#define VBU_NUMBERS 0
|
||||||
#define VBU_NONE 0
|
#define VBU_OUTSIDE 0
|
||||||
#define VBU_NUMBER 1
|
#define VBU_PREFIX_0X 0
|
||||||
#define VBU_NUMBERS 0
|
#define VBU_PREFIX_DOLLAR 1
|
||||||
#define VBU_OUTSIDE 0
|
#define VBU_PREFIX_NUMBER 1
|
||||||
#define VBU_SPLIT 1
|
#define VBU_RELATIVE 1
|
||||||
#define VBU_UPPER 0
|
#define VBU_SPLIT 1
|
||||||
#define VBU_Z 1
|
#define VBU_SUFFIX_H 2
|
||||||
|
#define VBU_UPPER 0
|
||||||
|
#define VBU_Z 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -44,13 +46,14 @@ extern "C" {
|
|||||||
/* Disassembler text options */
|
/* Disassembler text options */
|
||||||
typedef struct { /* Defaults listed first */
|
typedef struct { /* Defaults listed first */
|
||||||
uint8_t bcondNotation; /* JOINED, SPLIT */
|
uint8_t bcondNotation; /* JOINED, SPLIT */
|
||||||
|
uint8_t branchNotation; /* ABSOLUTE, RELATIVE */
|
||||||
uint8_t conditionCase; /* LOWER, UPPER */
|
uint8_t conditionCase; /* LOWER, UPPER */
|
||||||
uint8_t conditionCL; /* L, C */
|
uint8_t conditionCL; /* L, C */
|
||||||
uint8_t conditionEZ; /* Z, E */
|
uint8_t conditionEZ; /* Z, E */
|
||||||
uint8_t conditionNotation; /* NAMES, NUMBERS */
|
uint8_t conditionNotation; /* NAMES, NUMBERS */
|
||||||
uint8_t hexCase; /* UPPER, LOWER */
|
uint8_t hexCase; /* UPPER, LOWER */
|
||||||
uint8_t hexNotation; /* 0X, H, DOLLAR */
|
uint8_t hexNotation; /* PREFIX_0X, SUFFIX_H, PREFIX_DOLLAR */
|
||||||
uint8_t immediateNotation; /* NONE, NUMBER */
|
uint8_t immediateNotation; /* NONE, SUFFIX_NUMBER */
|
||||||
uint8_t memoryNotation; /* OUTSIDE, INSIDE */
|
uint8_t memoryNotation; /* OUTSIDE, INSIDE */
|
||||||
uint8_t mnemonicCase; /* UPPER, LOWER */
|
uint8_t mnemonicCase; /* UPPER, LOWER */
|
||||||
uint8_t operandOrder; /* DEST_LAST, DEST_FIRST */
|
uint8_t operandOrder; /* DEST_LAST, DEST_FIRST */
|
||||||
@@ -66,7 +69,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Parsed */
|
/* Parsed */
|
||||||
uint32_t address; /* Memory address */
|
uint32_t address; /* Memory address */
|
||||||
uint16_t code[4]; /* Instruction bytes */
|
uint8_t code[4]; /* Instruction bytes */
|
||||||
uint8_t codeLength; /* Number of items in code */
|
uint8_t codeLength; /* Number of items in code */
|
||||||
uint8_t isPC; /* Set if PC is on this line */
|
uint8_t isPC; /* Set if PC is on this line */
|
||||||
|
|
||||||
@@ -85,10 +88,10 @@ typedef struct {
|
|||||||
|
|
||||||
/******************************* API Commands ********************************/
|
/******************************* API Commands ********************************/
|
||||||
|
|
||||||
VBUAPI int vbuCodeSize (VB *sim, uint32_t address);
|
VBUAPI int vbuCodeSize (VB *sim, uint32_t address);
|
||||||
VBUAPI VBU_DasmConfig* vbuDasmInit (VBU_DasmConfig *config);
|
VBUAPI VBU_DasmConfig* vbuDasmDefaults(VBU_DasmConfig *config);
|
||||||
VBUAPI VBU_DasmLine* vbuDisassemble(VB *sim, uint32_t address, VBU_DasmConfig *config, unsigned length, int line);
|
VBUAPI VBU_DasmLine* vbuDisassemble (VB *sim, uint32_t address, VBU_DasmConfig *config, unsigned length, int line);
|
||||||
VBUAPI void* vbuFromISX (void *bytes, size_t length, size_t *romLength);
|
VBUAPI void* vbuFromISX (void *bytes, size_t length, size_t *romLength);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user