mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-01 05:41:31 +00:00
better segment coloring in memory dump
This commit is contained in:
parent
fabe7b019b
commit
08e253751f
|
@ -138,10 +138,6 @@ div.mem_info a.selected {
|
||||||
.btn_recording {
|
.btn_recording {
|
||||||
color: #ff3333;
|
color: #ff3333;
|
||||||
}
|
}
|
||||||
.seg_code { color: #ff9966; }
|
|
||||||
.seg_data { color: #66ff66; }
|
|
||||||
.seg_stack { color: #ffff66; }
|
|
||||||
.seg_unknown { color: #cccccc; }
|
|
||||||
span.hilite {
|
span.hilite {
|
||||||
color: #ff66ff;
|
color: #ff66ff;
|
||||||
}
|
}
|
||||||
|
@ -413,6 +409,11 @@ div.markdown th {
|
||||||
border-color: #ffffff;
|
border-color: #ffffff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.seg_code { color: #ccddff; }
|
||||||
|
.seg_data { color: #aaeeaa; }
|
||||||
|
.seg_io { color: #ffcccc; }
|
||||||
|
.seg_stack { color: #ffff66; }
|
||||||
|
.seg_unknown { color: #cccccc; }
|
||||||
.segment.segment-ram {
|
.segment.segment-ram {
|
||||||
background-color:#aaeeaa;
|
background-color:#aaeeaa;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ TODO:
|
||||||
- game starts even if switched away before first load
|
- game starts even if switched away before first load
|
||||||
- vcs: break on # of lines changed (maybe using getRasterPosition?)
|
- vcs: break on # of lines changed (maybe using getRasterPosition?)
|
||||||
- profiler restarts when paused
|
- profiler restarts when paused
|
||||||
|
- it's pretty easy to add a new file named like a library file (bcd.c)
|
||||||
|
|
||||||
WEB WORKER FORMAT
|
WEB WORKER FORMAT
|
||||||
|
|
||||||
|
|
|
@ -43,15 +43,25 @@
|
||||||
#define APU_PULSE_CONTROL(channel,duty,decay)\
|
#define APU_PULSE_CONTROL(channel,duty,decay)\
|
||||||
APU.pulse[channel].control = (duty) | (decay);
|
APU.pulse[channel].control = (duty) | (decay);
|
||||||
|
|
||||||
|
#define APU_PULSE_SWEEP(channel,period,shift,up)\
|
||||||
|
APU.pulse[channel].ramp = 0x80 | (period<<4) | (up?8:0) | shift;
|
||||||
|
|
||||||
|
#define APU_PULSE_SWEEP_DISABLE(channel)\
|
||||||
|
APU.pulse[channel].ramp = 0;
|
||||||
|
|
||||||
// triangle channel
|
// triangle channel
|
||||||
#define TRIANGLE_LC_HALT 0x80
|
#define TRIANGLE_LC_HALT 0x80
|
||||||
#define TRIANGLE_LC_MASK 0x7f
|
#define TRIANGLE_LC_MASK 0x7f
|
||||||
|
|
||||||
|
#define APU_TRIANGLE_LENGTH(period,len)\
|
||||||
|
APU.triangle.counter = 0x7f;\
|
||||||
|
APU.triangle.period_low = (period)&0xff;\
|
||||||
|
APU.triangle.len_period_high = (((period)>>8)&7) | ((len)<<3);
|
||||||
|
|
||||||
#define APU_TRIANGLE_SUSTAIN(period)\
|
#define APU_TRIANGLE_SUSTAIN(period)\
|
||||||
APU.triangle.counter = 0xc0;\
|
APU.triangle.counter = 0xff;\
|
||||||
APU.triangle.period_low = (period) & 0xff;\
|
APU.triangle.period_low = (period)&0xff;\
|
||||||
APU.triangle.len_period_high = (period) >> 8;
|
APU.triangle.len_period_high = (((period)>>8)&7);
|
||||||
|
|
||||||
// noise channel
|
// noise channel
|
||||||
#define NOISE_ENVLOOP 0x20
|
#define NOISE_ENVLOOP 0x20
|
||||||
|
|
100
presets/nes/aputest.c
Normal file
100
presets/nes/aputest.c
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "neslib.h"
|
||||||
|
|
||||||
|
#include "apu.h"
|
||||||
|
//#link "apu.c"
|
||||||
|
|
||||||
|
// link the pattern table into CHR ROM
|
||||||
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
|
typedef struct APUParam {
|
||||||
|
byte chmask;
|
||||||
|
const char* name;
|
||||||
|
word valmask;
|
||||||
|
} APUParam;
|
||||||
|
|
||||||
|
#define APU_DEFCOUNT 20
|
||||||
|
|
||||||
|
const APUParam APU_DEFS[APU_DEFCOUNT] = {
|
||||||
|
{0x01, "Pulse1 Period", 0x7ff },
|
||||||
|
{0x01, "Pulse1 Duty", 0xc0 },
|
||||||
|
{0x01, "Pulse1 Decay", 0x0f },
|
||||||
|
{0x01, "Pulse1 Length", 0x0f },
|
||||||
|
{0x01, "Pulse1 Sweep Period", 0x07 },
|
||||||
|
{0x01, "Pulse1 Sweep Rate", 0x07 },
|
||||||
|
{0x01, "Pulse1 Sweep Up?", 0x01 },
|
||||||
|
{0x02, "Pulse2 Period", 0x7ff },
|
||||||
|
{0x02, "Pulse2 Duty", 0xc0 },
|
||||||
|
{0x02, "Pulse2 Decay", 0x0f },
|
||||||
|
{0x02, "Pulse2 Length", 0x0f },
|
||||||
|
{0x02, "Pulse2 Sweep Period", 0x07 },
|
||||||
|
{0x02, "Pulse2 Sweep Rate", 0x07 },
|
||||||
|
{0x02, "Pulse2 Sweep Up?", 0x01 },
|
||||||
|
{0x04, "Triangle Period", 0x7ff },
|
||||||
|
{0x04, "Triangle Length", 0x0f },
|
||||||
|
{0x08, "Noise Period", 0x0f },
|
||||||
|
{0x08, "Noise Decay", 0x0f },
|
||||||
|
{0x08, "Noise Length", 0x0f },
|
||||||
|
{0x08, "Noise Buzz", NOISE_PERIOD_BUZZ },
|
||||||
|
};
|
||||||
|
|
||||||
|
word enmask;
|
||||||
|
word vals[APU_DEFCOUNT];
|
||||||
|
|
||||||
|
void random_sound() {
|
||||||
|
byte i;
|
||||||
|
|
||||||
|
do {
|
||||||
|
enmask = rand() & 15; // all except DMC
|
||||||
|
} while (enmask == 0);
|
||||||
|
|
||||||
|
for (i=0; i<APU_DEFCOUNT; i++) {
|
||||||
|
vals[i] = rand() & APU_DEFS[i].valmask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_sound() {
|
||||||
|
byte i;
|
||||||
|
char buf[32];
|
||||||
|
for (i=0; i<APU_DEFCOUNT; i++) {
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
if (enmask & APU_DEFS[i].chmask) {
|
||||||
|
sprintf(buf, "%2d %19s %5d", i, APU_DEFS[i].name, vals[i]);
|
||||||
|
}
|
||||||
|
vram_adr(NTADR_A(1,i+1));
|
||||||
|
vram_write(buf, 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void play_sound() {
|
||||||
|
APU_ENABLE(enmask);
|
||||||
|
APU_PULSE_DECAY(0, vals[0], vals[1], vals[2], vals[3]);
|
||||||
|
APU_PULSE_SWEEP(0, vals[4], vals[5], vals[6]);
|
||||||
|
APU_PULSE_DECAY(1, vals[7], vals[8], vals[9], vals[10]);
|
||||||
|
APU_PULSE_SWEEP(1, vals[11], vals[12], vals[13]);
|
||||||
|
APU_TRIANGLE_LENGTH(vals[14], vals[15]);
|
||||||
|
APU_NOISE_DECAY(vals[16]|vals[19], vals[17], vals[18]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
pal_col(1,0x04);
|
||||||
|
pal_col(2,0x20);
|
||||||
|
pal_col(3,0x30);
|
||||||
|
vram_adr(NTADR_A(0,26));
|
||||||
|
vram_write(" Space=New Sound, Enter=Replay ", 32);
|
||||||
|
apu_init();
|
||||||
|
while(1) {
|
||||||
|
ppu_off();
|
||||||
|
if (!(pad_state(0) & PAD_START)) {
|
||||||
|
random_sound();
|
||||||
|
}
|
||||||
|
print_sound();
|
||||||
|
play_sound();
|
||||||
|
ppu_on_all();//enable rendering
|
||||||
|
while (!pad_trigger(0)) ; // wait for key
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,21 +2,12 @@
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
word bcd_add(word a, word b) {
|
word bcd_add(word a, word b) {
|
||||||
word result = 0;
|
register word c, d; // intermediate values
|
||||||
byte c = 0;
|
c = a + 0x0666; // add 6 to each BCD digit
|
||||||
byte shift = 0;
|
d = c ^ b; // sum without carry propagation
|
||||||
while (shift < 16) {
|
c += b; // provisional sum
|
||||||
byte d = (a & 0xf) + (b & 0xf) + c;
|
d = ~(c ^ d) & 0x1110; // just the BCD carry bits
|
||||||
c = 0;
|
d = (d >> 2) | (d >> 3); // correction
|
||||||
while (d >= 10) {
|
return c - d; // corrected BCD sum
|
||||||
++c;
|
|
||||||
d -= 10;
|
|
||||||
}
|
|
||||||
result |= d << shift;
|
|
||||||
shift += 4;
|
|
||||||
a >>= 4;
|
|
||||||
b >>= 4;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
|
|
||||||
unsigned int bcd_add(unsigned int a, unsigned int b);
|
unsigned int bcd_add(unsigned int a, unsigned int b);
|
||||||
|
unsigned int bcd_add2(unsigned int a, unsigned int b);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -24,9 +24,16 @@ extern byte updptr;
|
||||||
VRAMBUF_SET(b)\
|
VRAMBUF_SET(b)\
|
||||||
asm("inc %v", updptr);
|
asm("inc %v", updptr);
|
||||||
|
|
||||||
|
// C versions of macros
|
||||||
//#define VRAMBUF_SET(b) updbuf[updptr] = (b);
|
//#define VRAMBUF_SET(b) updbuf[updptr] = (b);
|
||||||
//#define VRAMBUF_ADD(b) VRAMBUF_SET(b); ++updptr
|
//#define VRAMBUF_ADD(b) VRAMBUF_SET(b); ++updptr
|
||||||
|
|
||||||
|
// macro to add a raw header (useful for single bytes)
|
||||||
|
#define VRAMBUF_PUT(addr,len,flags)\
|
||||||
|
VRAMBUF_ADD(((addr) >> 8) | (flags));\
|
||||||
|
VRAMBUF_ADD(addr);\
|
||||||
|
VRAMBUF_ADD(len);
|
||||||
|
|
||||||
// add EOF marker to buffer (but don't increment pointer)
|
// add EOF marker to buffer (but don't increment pointer)
|
||||||
void cendbuf(void);
|
void cendbuf(void);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ const JSNES_PRESETS = [
|
||||||
{id:'statusbar.c', name:'Split Status Bar'},
|
{id:'statusbar.c', name:'Split Status Bar'},
|
||||||
{id:'horizmask.c', name:'Offscreen Scrolling'},
|
{id:'horizmask.c', name:'Offscreen Scrolling'},
|
||||||
{id:'attributes.c', name:'Attribute Table + Pixels'},
|
{id:'attributes.c', name:'Attribute Table + Pixels'},
|
||||||
|
{id:'aputest.c', name:'Sound Tester'},
|
||||||
{id:'music.c', name:'Music Player'},
|
{id:'music.c', name:'Music Player'},
|
||||||
{id:'siegegame.c', name:'Siege Game'},
|
{id:'siegegame.c', name:'Siege Game'},
|
||||||
{id:'shoot2.c', name:'Solarian Game'},
|
{id:'shoot2.c', name:'Solarian Game'},
|
||||||
|
|
30
src/views.ts
30
src/views.ts
|
@ -710,17 +710,27 @@ export class MemoryView implements ProjectView {
|
||||||
|
|
||||||
// TODO: use segments list?
|
// TODO: use segments list?
|
||||||
getMemorySegment(a:number) : string {
|
getMemorySegment(a:number) : string {
|
||||||
if (!compparams) return 'unknown';
|
if (compparams) {
|
||||||
if (a >= compparams.data_start && a < compparams.data_start+compparams.data_size) {
|
if (a >= compparams.data_start && a < compparams.data_start+compparams.data_size) {
|
||||||
if (platform.getSP && a >= platform.getSP() - 15)
|
if (platform.getSP && a >= platform.getSP() - 15)
|
||||||
return 'stack';
|
return 'stack';
|
||||||
else
|
else
|
||||||
return 'data';
|
return 'data';
|
||||||
|
}
|
||||||
|
else if (a >= compparams.code_start && a < compparams.code_start+(compparams.code_size||compparams.rom_size))
|
||||||
|
return 'code';
|
||||||
}
|
}
|
||||||
else if (a >= compparams.code_start && a < compparams.code_start+(compparams.code_size||compparams.rom_size))
|
var segments = current_project.segments;
|
||||||
return 'code';
|
if (segments) {
|
||||||
else
|
for (var seg of segments) {
|
||||||
return 'unknown';
|
if (a >= seg.start && a < seg.start+seg.size) {
|
||||||
|
if (seg.type == 'rom') return 'code';
|
||||||
|
if (seg.type == 'ram') return 'data';
|
||||||
|
if (seg.type == 'io') return 'io';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
findMemoryWindowLine(a:number) : number {
|
findMemoryWindowLine(a:number) : number {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user