줄바꿈을 LF로 통일
서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다. CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다. 내용은 바뀌지 않았습니다.
This commit is contained in:
1 parent
40615838ac
commit
2d48091205
623 files changed
+501372
-501365
No files matched your search
+47
-47
@@ -1,47 +1,47 @@
|
||||
0 3
|
||||
B 0.2
|
||||
0 2
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
A 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
0 120
|
||||
A 0.2
|
||||
0 1
|
||||
B 0.2
|
||||
0 3
|
||||
C 0.2
|
||||
0 2
|
||||
A 0.2
|
||||
A 0.2
|
||||
0 1
|
||||
B 0.2
|
||||
0 10
|
||||
0 3
|
||||
B 0.2
|
||||
0 2
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
A 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.6
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
B 0.2
|
||||
0 0.8
|
||||
0 120
|
||||
A 0.2
|
||||
0 1
|
||||
B 0.2
|
||||
0 3
|
||||
C 0.2
|
||||
0 2
|
||||
A 0.2
|
||||
A 0.2
|
||||
0 1
|
||||
B 0.2
|
||||
0 10
|
||||
+114
-114
@@ -1,114 +1,114 @@
|
||||
/* PC test of the Paradise T7 app logic (t7app.c): screen, clock, save, catching up, figures.
|
||||
* happ <rom> [figure...] commands on stdin:
|
||||
* w <s> run s seconds (rtc counts along, app_clock every 2 s)
|
||||
* slow <s> run s seconds, but the rtc counts twice as fast (emulation too slow)
|
||||
* p A|B|C|W press (W = wheel short = figure menu)
|
||||
* poke <h> <m> <s> set the game clock
|
||||
* t print the game clock
|
||||
* save <f> / load <f> [pause_s] save state / load it after a pause (catch up)
|
||||
* s <file.ppm> screenshot of the 128x128 screen
|
||||
*/
|
||||
#include "../src/core/t7.h"
|
||||
#include "../src/app/t7app.h"
|
||||
#include <stdio.h>
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
void app_wheel_short(void);
|
||||
static unsigned char *rd(const char *f, size_t *n) { FILE *x = fopen(f, "rb"); fseek(x, 0, 2); *n = ftell(x); fseek(x, 0, 0); unsigned char *p = malloc(*n); if (fread(p, 1, *n, x)) {} fclose(x); return p; }
|
||||
static uint16_t fb[128][128]; static int rx0, rx1, ry;
|
||||
static uint32_t g_rtc = 1000000, g_ms;
|
||||
static T7Cfg cfg = { T7_MAGIC, 1, 0, 0, 0, 0, {{0}}, 0 };
|
||||
static const uint8_t *figs[T7_FIG_MAX];
|
||||
uint32_t plat_rtc(void) { return g_rtc; }
|
||||
void plat_vol(int v) { (void)v; }
|
||||
void plat_bat(char *s) { const char *t = "2.84V 80%"; int i = 0; while ((s[i] = t[i])) i++; }
|
||||
void plat_rect(int x0, int y0, int x1, int y1) { rx0 = x0; rx1 = x1; ry = y0; (void)y1; }
|
||||
void plat_row(const uint16_t *px, int n) { for (int i = 0; i < n && rx0 + i < 128; i++) fb[ry][rx0 + i] = px[i]; ry++; }
|
||||
void plat_rect_end(void) {}
|
||||
const uint8_t *plat_fig_ptr(int i) { return figs[i]; }
|
||||
static uint8_t store[T7_STORE_LEN]; static int have_store;
|
||||
int plat_store_load(uint8_t *b, uint32_t n) { if (!have_store) return 0; memcpy(b, store, n); return 1; }
|
||||
void plat_store_write(const uint8_t *b, uint32_t n) { memcpy(store, b, n); have_store = 1; printf("store: bg=%d size=%d pixel=%d note=%d\n", b[4], b[8], b[9], b[32] == 'T'); }
|
||||
static int keys, dark;
|
||||
extern uint8_t g_t7_dark; int app_bell(void);
|
||||
static int icon9_px(void) { int n = 0; for (int y = 106; y < 126; y++) for (int x = 4*128/5 + 2; x < 4*128/5 + 22; x++) if (fb[y][x] != fb[105][0]) n = fb[y][x]; return n; }
|
||||
static void run(double s, int rtcx)
|
||||
{
|
||||
int n = (int)(s * 500 + 0.5);
|
||||
for (int i = 0; i < n; i++) {
|
||||
g_ms += 2;
|
||||
t7_set_buttons((uint8_t)app_keys((uint32_t)keys, g_ms));
|
||||
app_tick(g_ms);
|
||||
t7_step_cycles(T7_CLOCK_RATE / 500);
|
||||
{ static int pt; static uint32_t lt; uint8_t lv; int tn = t7_snd_tone_hz(&lv) != 0; if (tn && !pt) { if (g_ms - lt > 5000) { uint8_t ic[10]; t7_get_icons(ic); printf("TONE %02d:%02d ic %d calls %02x %02x %02x %02x %02x %02x %02x hh %02x %02x\n", t7_ram_read(0x306), t7_ram_read(0x307), ic[9], t7_ram_read(0x3b0), t7_ram_read(0x3b1), t7_ram_read(0x3b2), t7_ram_read(0x3b3), t7_ram_read(0x3b4), t7_ram_read(0x3b5), t7_ram_read(0x3b6), t7_ram_read(0x326), t7_ram_read(0x327)); } lt = g_ms; } pt = tn; }
|
||||
{ static uint32_t cs; static int pc; int c = t7_ram_read(0x3b0) | t7_ram_read(0x3b1) | t7_ram_read(0x3b2) | t7_ram_read(0x3b4) | t7_ram_read(0x3b5) | t7_ram_read(0x3b6); uint8_t ic[10]; t7_get_icons(ic);
|
||||
if (c && !pc) cs = g_ms; if (cs && ic[9]) { printf("CALL->ICON %u ms\n", g_ms - cs); cs = 0; } if (!c) cs = 0; pc = c != 0; }
|
||||
if (g_ms % 1000 == 0) g_rtc += (uint32_t)rtcx;
|
||||
if (g_ms % 500 == 0) app_setup_fill(g_rtc);
|
||||
if (g_ms % 2000 == 0) app_clock(g_rtc, 0);
|
||||
if (dark) { g_t7_dark = 1; if (app_bell()) { dark = 0; g_t7_dark = 0; app_render(1); printf("bell wake at %02d:%02d px %d\n", t7_ram_read(0x306), t7_ram_read(0x307), icon9_px()); } continue; }
|
||||
g_t7_dark = 0;
|
||||
if (g_ms % 34 == 0) { app_render(0); static int pb; int b = app_bell(); if (b != pb) { printf("bell %d at %02d:%02d px %d\n", b, t7_ram_read(0x306), t7_ram_read(0x307), icon9_px()); pb = b; } }
|
||||
}
|
||||
}
|
||||
static void shot(const char *f)
|
||||
{
|
||||
app_render(0);
|
||||
FILE *o = fopen(f, "wb"); fprintf(o, "P6 128 128 255\n");
|
||||
for (int y = 0; y < 128; y++) for (int x = 0; x < 128; x++) { uint16_t p = fb[y][x]; fputc((p >> 11) << 3, o); fputc(((p >> 5) & 63) << 2, o); fputc((p & 31) << 3, o); }
|
||||
fclose(o);
|
||||
}
|
||||
static void prog(int d, int t) { if (d == t) printf("caught up %d hours\n", t); }
|
||||
int main(int c, char **v)
|
||||
{
|
||||
size_t n; unsigned char *rom = rd(v[1], &n); host_set_rom(rom, n);
|
||||
for (int i = 2; i < c && i - 2 < T7_FIG_MAX; i++) {
|
||||
size_t fn; figs[i - 2] = rd(v[i], &fn); cfg.fig[i - 2].len = (uint32_t)fn;
|
||||
const char *b = strrchr(v[i], '_'); b = b ? b + 1 : v[i]; int k = 0;
|
||||
while (b[k] && b[k] != '.' && k < 15) { cfg.fig[i - 2].name[k] = b[k]; k++; }
|
||||
cfg.nfig++;
|
||||
}
|
||||
if (getenv("EE")) { size_t en; unsigned char *e = rd(getenv("EE"), &en); size_t m2 = en; extern void persist_restore_page(int, const uint8_t *); for (int i = 0; i < 16 && (size_t)(i + 1) * 256 <= en; i++) persist_restore_page(i, e + (m2 == 4098 ? 2 : 0) + i * 256); } /* EE=save (Studio save.bin: u16 have first) */
|
||||
app_init(&cfg);
|
||||
t7_init();
|
||||
t7_snd_config(T7_CLOCK_RATE, 16000); t7_snd_capture(0); t7_snd_set_mode(1);
|
||||
app_render(1);
|
||||
char l[256];
|
||||
while (fgets(l, sizeof l, stdin)) {
|
||||
char cmd[16], a[200]; double x = 0; int k = sscanf(l, "%15s %199s %lf", cmd, a, &x);
|
||||
if (k < 1) continue;
|
||||
if (!strcmp(cmd, "w")) run(atof(a), 1);
|
||||
else if (!strcmp(cmd, "slow")) run(atof(a), 2);
|
||||
else if (!strcmp(cmd, "p")) {
|
||||
if (a[0] == 'W') { app_wheel_short(); run(0.3, 1); }
|
||||
else { keys = a[0] == 'A' ? 1 : a[0] == 'B' ? 2 : 4; run(0.2, 1); keys = 0; run(k > 2 ? x : 0.8, 1); }
|
||||
}
|
||||
else if (!strcmp(cmd, "poke")) { int h, m, s2; sscanf(l, "%*s %d %d %d", &h, &m, &s2); t7_ram_write(0x306, h); t7_ram_write(0x307, m); t7_ram_write(t7_rtc_sec_addr(), s2); }
|
||||
else if (!strcmp(cmd, "t")) printf("game %02d:%02d:%02d day %d.%d rtc %u fig %d species %02x\n", t7_ram_read(0x306), t7_ram_read(0x307), t7_ram_read(t7_rtc_sec_addr()), t7_ram_read(0x305), t7_ram_read(0x304), g_rtc, t7_figure_get(), t7_ram_read(0x22));
|
||||
else if (!strcmp(cmd, "save")) { static uint8_t b[4096]; uint32_t m = app_save(b, sizeof b); FILE *o = fopen(a, "wb"); fwrite(b, 1, m, o); fclose(o); printf("saved %u bytes\n", m); }
|
||||
else if (!strcmp(cmd, "load")) {
|
||||
size_t m; unsigned char *b = rd(a, &m); uint32_t sv;
|
||||
g_rtc += (uint32_t)x;
|
||||
t7_init();
|
||||
printf("load %s\n", app_load(b, (uint32_t)m, &sv) ? "ok" : "FAILED");
|
||||
if (app_clock_hard(g_rtc)) printf("clock from the Paradise\n"); else app_catchup(g_rtc, prog);
|
||||
}
|
||||
else if (!strcmp(cmd, "i")) { uint8_t ic[10]; t7_get_icons(ic); printf("icons"); for (int q = 0; q < 10; q++) printf(" %d", ic[q]); printf(" ram326 %02x %02x 3b0", t7_ram_read(0x326), t7_ram_read(0x327)); for (int q = 0; q < 7; q++) printf(" %02x", t7_ram_read((uint16_t)(0x3b0 + q))); printf(" t %02d:%02d\n", t7_ram_read(0x306), t7_ram_read(0x307)); }
|
||||
else if (!strcmp(cmd, "s")) shot(a);
|
||||
else if (!strcmp(cmd, "para")) { /* para <y> <m> <d> <h> <mi>: the Paradise's time now, clock flag on */
|
||||
int y, mo, d, h, mi; sscanf(l, "%*s %d %d %d %d %d", &y, &mo, &d, &h, &mi);
|
||||
int yy = y - (mo <= 2), era = yy / 400, yoe = yy - era * 400, doy = (153 * (mo + (mo > 2 ? -3 : 9)) + 2) / 5 + d - 1, doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
|
||||
g_para_time = (uint32_t)(era * 146097 + doe - 719468) * 86400u + (uint32_t)(h * 3600 + mi * 60); g_para_cnt = g_rtc; cfg.flags |= 2u;
|
||||
}
|
||||
else if (!strcmp(cmd, "wall")) { int h, m, d, mo; sscanf(l, "%*s %d %d %d %d", &h, &m, &d, &mo); cfg.wall_cnt = g_rtc; cfg.wall_sod = (uint32_t)(h * 3600 + m * 60); cfg.wall_ymd = (2026u << 16) | (uint32_t)(mo << 8 | d); }
|
||||
else if (!strcmp(cmd, "store")) app_store();
|
||||
else if (!strcmp(cmd, "set")) { extern T7Set g_set; int sz = 0, px = 0, gr = -1; sscanf(l, "%*s %d %d %d", &sz, &px, &gr); g_set.size = (uint8_t)sz; g_set.pixel = (uint8_t)px; if (gr >= 0) g_set.grid = (uint8_t)gr; app_dim(1); app_dim(0); } /* set <size> <pixel> [grid] */
|
||||
else if (!strcmp(cmd, "reboot")) { t7_init(); app_init(&cfg); app_render(1); }
|
||||
else if (!strcmp(cmd, "wb")) { unsigned ad, v; sscanf(l, "%*s %x %x", &ad, &v); t7_ram_write((uint16_t)ad, (uint8_t)v); } /* test30 */
|
||||
else if (!strcmp(cmd, "dump")) { FILE *o = fopen(a, "wb"); for (int i = 0; i < 0x600; i++) fputc(t7_ram_read((uint16_t)i), o); fclose(o); }
|
||||
else if (!strcmp(cmd, "dark")) dark = atoi(a);
|
||||
else if (!strcmp(cmd, "noclk")) cfg.flags &= ~2u; /* clock not from the Paradise */
|
||||
else if (!strcmp(cmd, "q")) break;
|
||||
fflush(stdout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* PC test of the Paradise T7 app logic (t7app.c): screen, clock, save, catching up, figures.
|
||||
* happ <rom> [figure...] commands on stdin:
|
||||
* w <s> run s seconds (rtc counts along, app_clock every 2 s)
|
||||
* slow <s> run s seconds, but the rtc counts twice as fast (emulation too slow)
|
||||
* p A|B|C|W press (W = wheel short = figure menu)
|
||||
* poke <h> <m> <s> set the game clock
|
||||
* t print the game clock
|
||||
* save <f> / load <f> [pause_s] save state / load it after a pause (catch up)
|
||||
* s <file.ppm> screenshot of the 128x128 screen
|
||||
*/
|
||||
#include "../src/core/t7.h"
|
||||
#include "../src/app/t7app.h"
|
||||
#include <stdio.h>
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
void app_wheel_short(void);
|
||||
static unsigned char *rd(const char *f, size_t *n) { FILE *x = fopen(f, "rb"); fseek(x, 0, 2); *n = ftell(x); fseek(x, 0, 0); unsigned char *p = malloc(*n); if (fread(p, 1, *n, x)) {} fclose(x); return p; }
|
||||
static uint16_t fb[128][128]; static int rx0, rx1, ry;
|
||||
static uint32_t g_rtc = 1000000, g_ms;
|
||||
static T7Cfg cfg = { T7_MAGIC, 1, 0, 0, 0, 0, {{0}}, 0 };
|
||||
static const uint8_t *figs[T7_FIG_MAX];
|
||||
uint32_t plat_rtc(void) { return g_rtc; }
|
||||
void plat_vol(int v) { (void)v; }
|
||||
void plat_bat(char *s) { const char *t = "2.84V 80%"; int i = 0; while ((s[i] = t[i])) i++; }
|
||||
void plat_rect(int x0, int y0, int x1, int y1) { rx0 = x0; rx1 = x1; ry = y0; (void)y1; }
|
||||
void plat_row(const uint16_t *px, int n) { for (int i = 0; i < n && rx0 + i < 128; i++) fb[ry][rx0 + i] = px[i]; ry++; }
|
||||
void plat_rect_end(void) {}
|
||||
const uint8_t *plat_fig_ptr(int i) { return figs[i]; }
|
||||
static uint8_t store[T7_STORE_LEN]; static int have_store;
|
||||
int plat_store_load(uint8_t *b, uint32_t n) { if (!have_store) return 0; memcpy(b, store, n); return 1; }
|
||||
void plat_store_write(const uint8_t *b, uint32_t n) { memcpy(store, b, n); have_store = 1; printf("store: bg=%d size=%d pixel=%d note=%d\n", b[4], b[8], b[9], b[32] == 'T'); }
|
||||
static int keys, dark;
|
||||
extern uint8_t g_t7_dark; int app_bell(void);
|
||||
static int icon9_px(void) { int n = 0; for (int y = 106; y < 126; y++) for (int x = 4*128/5 + 2; x < 4*128/5 + 22; x++) if (fb[y][x] != fb[105][0]) n = fb[y][x]; return n; }
|
||||
static void run(double s, int rtcx)
|
||||
{
|
||||
int n = (int)(s * 500 + 0.5);
|
||||
for (int i = 0; i < n; i++) {
|
||||
g_ms += 2;
|
||||
t7_set_buttons((uint8_t)app_keys((uint32_t)keys, g_ms));
|
||||
app_tick(g_ms);
|
||||
t7_step_cycles(T7_CLOCK_RATE / 500);
|
||||
{ static int pt; static uint32_t lt; uint8_t lv; int tn = t7_snd_tone_hz(&lv) != 0; if (tn && !pt) { if (g_ms - lt > 5000) { uint8_t ic[10]; t7_get_icons(ic); printf("TONE %02d:%02d ic %d calls %02x %02x %02x %02x %02x %02x %02x hh %02x %02x\n", t7_ram_read(0x306), t7_ram_read(0x307), ic[9], t7_ram_read(0x3b0), t7_ram_read(0x3b1), t7_ram_read(0x3b2), t7_ram_read(0x3b3), t7_ram_read(0x3b4), t7_ram_read(0x3b5), t7_ram_read(0x3b6), t7_ram_read(0x326), t7_ram_read(0x327)); } lt = g_ms; } pt = tn; }
|
||||
{ static uint32_t cs; static int pc; int c = t7_ram_read(0x3b0) | t7_ram_read(0x3b1) | t7_ram_read(0x3b2) | t7_ram_read(0x3b4) | t7_ram_read(0x3b5) | t7_ram_read(0x3b6); uint8_t ic[10]; t7_get_icons(ic);
|
||||
if (c && !pc) cs = g_ms; if (cs && ic[9]) { printf("CALL->ICON %u ms\n", g_ms - cs); cs = 0; } if (!c) cs = 0; pc = c != 0; }
|
||||
if (g_ms % 1000 == 0) g_rtc += (uint32_t)rtcx;
|
||||
if (g_ms % 500 == 0) app_setup_fill(g_rtc);
|
||||
if (g_ms % 2000 == 0) app_clock(g_rtc, 0);
|
||||
if (dark) { g_t7_dark = 1; if (app_bell()) { dark = 0; g_t7_dark = 0; app_render(1); printf("bell wake at %02d:%02d px %d\n", t7_ram_read(0x306), t7_ram_read(0x307), icon9_px()); } continue; }
|
||||
g_t7_dark = 0;
|
||||
if (g_ms % 34 == 0) { app_render(0); static int pb; int b = app_bell(); if (b != pb) { printf("bell %d at %02d:%02d px %d\n", b, t7_ram_read(0x306), t7_ram_read(0x307), icon9_px()); pb = b; } }
|
||||
}
|
||||
}
|
||||
static void shot(const char *f)
|
||||
{
|
||||
app_render(0);
|
||||
FILE *o = fopen(f, "wb"); fprintf(o, "P6 128 128 255\n");
|
||||
for (int y = 0; y < 128; y++) for (int x = 0; x < 128; x++) { uint16_t p = fb[y][x]; fputc((p >> 11) << 3, o); fputc(((p >> 5) & 63) << 2, o); fputc((p & 31) << 3, o); }
|
||||
fclose(o);
|
||||
}
|
||||
static void prog(int d, int t) { if (d == t) printf("caught up %d hours\n", t); }
|
||||
int main(int c, char **v)
|
||||
{
|
||||
size_t n; unsigned char *rom = rd(v[1], &n); host_set_rom(rom, n);
|
||||
for (int i = 2; i < c && i - 2 < T7_FIG_MAX; i++) {
|
||||
size_t fn; figs[i - 2] = rd(v[i], &fn); cfg.fig[i - 2].len = (uint32_t)fn;
|
||||
const char *b = strrchr(v[i], '_'); b = b ? b + 1 : v[i]; int k = 0;
|
||||
while (b[k] && b[k] != '.' && k < 15) { cfg.fig[i - 2].name[k] = b[k]; k++; }
|
||||
cfg.nfig++;
|
||||
}
|
||||
if (getenv("EE")) { size_t en; unsigned char *e = rd(getenv("EE"), &en); size_t m2 = en; extern void persist_restore_page(int, const uint8_t *); for (int i = 0; i < 16 && (size_t)(i + 1) * 256 <= en; i++) persist_restore_page(i, e + (m2 == 4098 ? 2 : 0) + i * 256); } /* EE=save (Studio save.bin: u16 have first) */
|
||||
app_init(&cfg);
|
||||
t7_init();
|
||||
t7_snd_config(T7_CLOCK_RATE, 16000); t7_snd_capture(0); t7_snd_set_mode(1);
|
||||
app_render(1);
|
||||
char l[256];
|
||||
while (fgets(l, sizeof l, stdin)) {
|
||||
char cmd[16], a[200]; double x = 0; int k = sscanf(l, "%15s %199s %lf", cmd, a, &x);
|
||||
if (k < 1) continue;
|
||||
if (!strcmp(cmd, "w")) run(atof(a), 1);
|
||||
else if (!strcmp(cmd, "slow")) run(atof(a), 2);
|
||||
else if (!strcmp(cmd, "p")) {
|
||||
if (a[0] == 'W') { app_wheel_short(); run(0.3, 1); }
|
||||
else { keys = a[0] == 'A' ? 1 : a[0] == 'B' ? 2 : 4; run(0.2, 1); keys = 0; run(k > 2 ? x : 0.8, 1); }
|
||||
}
|
||||
else if (!strcmp(cmd, "poke")) { int h, m, s2; sscanf(l, "%*s %d %d %d", &h, &m, &s2); t7_ram_write(0x306, h); t7_ram_write(0x307, m); t7_ram_write(t7_rtc_sec_addr(), s2); }
|
||||
else if (!strcmp(cmd, "t")) printf("game %02d:%02d:%02d day %d.%d rtc %u fig %d species %02x\n", t7_ram_read(0x306), t7_ram_read(0x307), t7_ram_read(t7_rtc_sec_addr()), t7_ram_read(0x305), t7_ram_read(0x304), g_rtc, t7_figure_get(), t7_ram_read(0x22));
|
||||
else if (!strcmp(cmd, "save")) { static uint8_t b[4096]; uint32_t m = app_save(b, sizeof b); FILE *o = fopen(a, "wb"); fwrite(b, 1, m, o); fclose(o); printf("saved %u bytes\n", m); }
|
||||
else if (!strcmp(cmd, "load")) {
|
||||
size_t m; unsigned char *b = rd(a, &m); uint32_t sv;
|
||||
g_rtc += (uint32_t)x;
|
||||
t7_init();
|
||||
printf("load %s\n", app_load(b, (uint32_t)m, &sv) ? "ok" : "FAILED");
|
||||
if (app_clock_hard(g_rtc)) printf("clock from the Paradise\n"); else app_catchup(g_rtc, prog);
|
||||
}
|
||||
else if (!strcmp(cmd, "i")) { uint8_t ic[10]; t7_get_icons(ic); printf("icons"); for (int q = 0; q < 10; q++) printf(" %d", ic[q]); printf(" ram326 %02x %02x 3b0", t7_ram_read(0x326), t7_ram_read(0x327)); for (int q = 0; q < 7; q++) printf(" %02x", t7_ram_read((uint16_t)(0x3b0 + q))); printf(" t %02d:%02d\n", t7_ram_read(0x306), t7_ram_read(0x307)); }
|
||||
else if (!strcmp(cmd, "s")) shot(a);
|
||||
else if (!strcmp(cmd, "para")) { /* para <y> <m> <d> <h> <mi>: the Paradise's time now, clock flag on */
|
||||
int y, mo, d, h, mi; sscanf(l, "%*s %d %d %d %d %d", &y, &mo, &d, &h, &mi);
|
||||
int yy = y - (mo <= 2), era = yy / 400, yoe = yy - era * 400, doy = (153 * (mo + (mo > 2 ? -3 : 9)) + 2) / 5 + d - 1, doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
|
||||
g_para_time = (uint32_t)(era * 146097 + doe - 719468) * 86400u + (uint32_t)(h * 3600 + mi * 60); g_para_cnt = g_rtc; cfg.flags |= 2u;
|
||||
}
|
||||
else if (!strcmp(cmd, "wall")) { int h, m, d, mo; sscanf(l, "%*s %d %d %d %d", &h, &m, &d, &mo); cfg.wall_cnt = g_rtc; cfg.wall_sod = (uint32_t)(h * 3600 + m * 60); cfg.wall_ymd = (2026u << 16) | (uint32_t)(mo << 8 | d); }
|
||||
else if (!strcmp(cmd, "store")) app_store();
|
||||
else if (!strcmp(cmd, "set")) { extern T7Set g_set; int sz = 0, px = 0, gr = -1; sscanf(l, "%*s %d %d %d", &sz, &px, &gr); g_set.size = (uint8_t)sz; g_set.pixel = (uint8_t)px; if (gr >= 0) g_set.grid = (uint8_t)gr; app_dim(1); app_dim(0); } /* set <size> <pixel> [grid] */
|
||||
else if (!strcmp(cmd, "reboot")) { t7_init(); app_init(&cfg); app_render(1); }
|
||||
else if (!strcmp(cmd, "wb")) { unsigned ad, v; sscanf(l, "%*s %x %x", &ad, &v); t7_ram_write((uint16_t)ad, (uint8_t)v); } /* test30 */
|
||||
else if (!strcmp(cmd, "dump")) { FILE *o = fopen(a, "wb"); for (int i = 0; i < 0x600; i++) fputc(t7_ram_read((uint16_t)i), o); fclose(o); }
|
||||
else if (!strcmp(cmd, "dark")) dark = atoi(a);
|
||||
else if (!strcmp(cmd, "noclk")) cfg.flags &= ~2u; /* clock not from the Paradise */
|
||||
else if (!strcmp(cmd, "q")) break;
|
||||
fflush(stdout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
/* Host build of the Paradise T7 app glue: ROM from a file, EEPROM pages in memory. */
|
||||
#include "../src/core/pebble_compat.h"
|
||||
#include <stdarg.h>
|
||||
static unsigned char *g_rom; static size_t g_rom_n;
|
||||
static unsigned char g_pages[16][256]; static unsigned char g_has[16];
|
||||
void host_set_rom(unsigned char *p, size_t n){ g_rom=p; g_rom_n=n; }
|
||||
void tama_log(const char *fmt, ...){ if(!getenv("T7LOG")) return; va_list a; va_start(a,fmt); vfprintf(stderr,fmt,a); va_end(a); }
|
||||
ResHandle resource_get_handle(int id){ (void)id; return g_rom?1:0; }
|
||||
size_t resource_size(ResHandle h){ (void)h; return g_rom_n; }
|
||||
size_t resource_load_byte_range(ResHandle h, size_t off, uint8_t *out, size_t len){ (void)h; if(off>=g_rom_n) return 0; if(off+len>g_rom_n) len=g_rom_n-off; memcpy(out,g_rom+off,len); return len; }
|
||||
const uint8_t *t7_compat_rom_mapped(void){ return g_rom; }
|
||||
bool persist_exists(uint32_t key){ return key>=100 && key<116 && g_has[key-100]; }
|
||||
int persist_read_data(uint32_t key, void *buf, size_t n){ if(!persist_exists(key)) return -1; if(n>256) n=256; memcpy(buf,g_pages[key-100],n); return (int)n; }
|
||||
status_t persist_write_data(uint32_t key, const void *buf, size_t n){ if(key<100||key>=116) return -1; if(n>256) n=256; memcpy(g_pages[key-100],buf,n); g_has[key-100]=1; return S_SUCCESS; }
|
||||
status_t persist_delete(uint32_t key){ if(key>=100&&key<116) g_has[key-100]=0; return S_SUCCESS; }
|
||||
void persist_flush_to_disk(void){}
|
||||
int persist_page_count(void){ return 16; }
|
||||
int persist_page_size(void){ return 256; }
|
||||
int persist_backup_page(int p, uint8_t *o){ memcpy(o,g_pages[p],256); return g_has[p]; }
|
||||
void persist_restore_page(int p, const uint8_t *i){ memcpy(g_pages[p],i,256); g_has[p]=1; }
|
||||
void t7_compat_set_rom_path(const char *p){ (void)p; }
|
||||
void t7_compat_set_eeprom_path(const char *p){ (void)p; }
|
||||
/* Host build of the Paradise T7 app glue: ROM from a file, EEPROM pages in memory. */
|
||||
#include "../src/core/pebble_compat.h"
|
||||
#include <stdarg.h>
|
||||
static unsigned char *g_rom; static size_t g_rom_n;
|
||||
static unsigned char g_pages[16][256]; static unsigned char g_has[16];
|
||||
void host_set_rom(unsigned char *p, size_t n){ g_rom=p; g_rom_n=n; }
|
||||
void tama_log(const char *fmt, ...){ if(!getenv("T7LOG")) return; va_list a; va_start(a,fmt); vfprintf(stderr,fmt,a); va_end(a); }
|
||||
ResHandle resource_get_handle(int id){ (void)id; return g_rom?1:0; }
|
||||
size_t resource_size(ResHandle h){ (void)h; return g_rom_n; }
|
||||
size_t resource_load_byte_range(ResHandle h, size_t off, uint8_t *out, size_t len){ (void)h; if(off>=g_rom_n) return 0; if(off+len>g_rom_n) len=g_rom_n-off; memcpy(out,g_rom+off,len); return len; }
|
||||
const uint8_t *t7_compat_rom_mapped(void){ return g_rom; }
|
||||
bool persist_exists(uint32_t key){ return key>=100 && key<116 && g_has[key-100]; }
|
||||
int persist_read_data(uint32_t key, void *buf, size_t n){ if(!persist_exists(key)) return -1; if(n>256) n=256; memcpy(buf,g_pages[key-100],n); return (int)n; }
|
||||
status_t persist_write_data(uint32_t key, const void *buf, size_t n){ if(key<100||key>=116) return -1; if(n>256) n=256; memcpy(g_pages[key-100],buf,n); g_has[key-100]=1; return S_SUCCESS; }
|
||||
status_t persist_delete(uint32_t key){ if(key>=100&&key<116) g_has[key-100]=0; return S_SUCCESS; }
|
||||
void persist_flush_to_disk(void){}
|
||||
int persist_page_count(void){ return 16; }
|
||||
int persist_page_size(void){ return 256; }
|
||||
int persist_backup_page(int p, uint8_t *o){ memcpy(o,g_pages[p],256); return g_has[p]; }
|
||||
void persist_restore_page(int p, const uint8_t *i){ memcpy(g_pages[p],i,256); g_has[p]=1; }
|
||||
void t7_compat_set_rom_path(const char *p){ (void)p; }
|
||||
void t7_compat_set_eeprom_path(const char *p){ (void)p; }
|
||||
+81
-81
@@ -1,81 +1,81 @@
|
||||
/* Host: boot the V7 ROM, press keys, save screenshots. hrun <rom> [figure]; stdin: p A|B|C [s] | w s | s file | q */
|
||||
#include "../src/core/t7.h"
|
||||
#include <stdio.h>
|
||||
#include "../src/core/t7_internal.h"
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
void figure_rom_set_active(const unsigned char* p, unsigned int n);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
#ifdef T7_STOP_DBG
|
||||
static long g_step; void t7_stop_dbg(int w){ static int n; if (getenv("SDBG") && n++ < 400) fprintf(stderr, "step %ld STOP 3007=%02x 3008=%02x keys=%x halted=%d irqmask=%02x%02x nmi=%02x\n", g_step, g_cpureg[7], g_cpureg[8], g_keys, g_t7_halted, g_cpureg[0x70], g_cpureg[0x71], g_cpureg[0x76]); (void)w; }
|
||||
#endif
|
||||
#ifdef T7_EEDBG
|
||||
static double g_now; void t7_eedbg(uint16_t a, uint8_t v){ static double last=-1; if (getenv("EEDBG") && g_now != last) { fprintf(stderr, "ee write at %.2f s: %03x=%02x\n", g_now, a, v); last = g_now; } }
|
||||
#endif
|
||||
static void frames(double s){ static int cyc; if(!cyc) cyc=getenv("CYC")?atoi(getenv("CYC")):40000; int n=(int)(s*100+0.5); for(int i=0;i<n;i++) { t7_step_cycles(cyc);
|
||||
#ifdef T7_EEDBG
|
||||
g_now += 0.01;
|
||||
#endif
|
||||
} }
|
||||
static void shot(const char *f){ uint8_t d[48*31], ic[10]; t7_get_display(d); t7_get_icons(ic);
|
||||
static const int pal[4]={0xE0,0xA0,0x60,0x20}; FILE*o=fopen(f,"wb"); fprintf(o,"P6 192 140 255\n");
|
||||
for(int y=0;y<140;y++) for(int x=0;x<192;x++){ int v=0xF0;
|
||||
if(y>=8&&y<132){ int yy=(y-8)/4, xx=x/4; if(yy<31) v=pal[d[yy*48+xx]]; }
|
||||
else { int k=x/(192/5)+(y>=132?5:0); v=ic[k]?pal[ic[k]]:0xF0; }
|
||||
fputc(v,o); fputc(v,o); fputc(v,o);} fclose(o); }
|
||||
int main(int c, char **v){ size_t n; unsigned char *rom=rd(v[1],&n); host_set_rom(rom,n);
|
||||
if(c>2){ size_t fn; unsigned char*f=rd(v[2],&fn); figure_rom_set_active(f,(unsigned)fn); t7_figure_set(1); }
|
||||
if (getenv("EE")) { size_t en; unsigned char *e=rd(getenv("EE"),&en); extern void persist_restore_page(int,const uint8_t*); for (int i=0;i<16 && (size_t)(i+1)*256<=en;i++) persist_restore_page(i,e+i*256); } /* EE=save: EEPROM from a file */
|
||||
if(!t7_init()){ printf("init failed\n"); return 1; }
|
||||
if (getenv("SND")) { extern void t7_snd_set_mode(int); t7_snd_set_mode(1); }
|
||||
#ifdef T7_JSR_HLE
|
||||
if (getenv("DARK")) g_t7_dark = 1; /* screen off as on the device */
|
||||
#endif
|
||||
char l[256]; while(fgets(l,sizeof l,stdin)){ char cmd[16],a[200]; double x=0; int k=sscanf(l,"%15s %199s %lf",cmd,a,&x); if(k<1) continue;
|
||||
if(!strcmp(cmd,"p")){ t7_set_buttons(a[0]=='A'?1:a[0]=='B'?2:4); frames(0.2); t7_set_buttons(0); frames(k>2?x:0.8); }
|
||||
else if(!strcmp(cmd,"w")) frames(atof(a));
|
||||
else if(!strcmp(cmd,"tl")){ /* tl <s>: tone list in 2 ms steps (hz x steps) */ extern uint32_t t7_snd_tone_hz(uint8_t*); uint32_t last=0xFFFFFFFF; int n=0; int m=(int)(atof(a)*500+0.5);
|
||||
for(int i=0;i<m;i++){ t7_step_cycles(8000); uint8_t lv; uint32_t hz=t7_snd_tone_hz(&lv); if(hz!=last){ if(n) printf("%u x%d\n",last,n); last=hz; n=0; } n++; } printf("%u x%d\nEND\n",last,n); }
|
||||
else if(!strcmp(cmd,"k")){ double g=0; sscanf(l,"%*s %*s %lf %lf",&x,&g); int m=a[0]=='A'?1:a[0]=='B'?2:4; /* k A hold gap: a quick press in 2 ms steps */
|
||||
t7_set_buttons(m); for(int i=0;i<(int)(x*500+0.5);i++) { t7_step_cycles(8000);
|
||||
#ifdef T7_STOP_DBG
|
||||
g_step++; if (getenv("TL")) fputc(g_t7_halted ? 'h' : 'r', stderr);
|
||||
#endif
|
||||
}
|
||||
#ifdef T7_STOP_DBG
|
||||
if (getenv("TL")) fputc('|', stderr);
|
||||
#endif
|
||||
t7_set_buttons(0); for(int i=0;i<(int)(g*500+0.5);i++) { t7_step_cycles(8000);
|
||||
#ifdef T7_STOP_DBG
|
||||
if (getenv("TL")) fputc(g_t7_halted ? 'H' : 'R', stderr);
|
||||
#endif
|
||||
}
|
||||
#ifdef T7_STOP_DBG
|
||||
if (getenv("TL")) fputc('\n', stderr);
|
||||
#endif
|
||||
}
|
||||
#ifdef T7_JSR_HLE
|
||||
else if(!strcmp(cmd,"dk")){ g_t7_dark=(uint8_t)atoi(a); } /* dk 1|0: screen off/on */
|
||||
#ifdef T7_WAKE_FRESH
|
||||
else if(!strcmp(cmd,"wake")){ extern uint32_t g_t7_blits; uint32_t b0=g_t7_blits, bt=0; int t=0; g_t7_dark=0; /* wake: on as T7_WAKE_FRESH (light after a drawn picture) */
|
||||
for(;;){ t7_step_cycles(8000); t+=2; if(g_t7_blits!=b0){ b0=g_t7_blits; bt=t; } if((bt && t-bt>=20) || t>=700) break; }
|
||||
printf("wake light after %d ms\n", t); }
|
||||
else if(!strcmp(cmd,"peek")){ extern uint32_t g_t7_blits; uint32_t b0=g_t7_blits, bt=0; int t=0; g_t7_dark=0; /* peek: one picture with the screen dark, then dark again */
|
||||
for(;;){ t7_step_cycles(8000); t+=2; if(g_t7_blits!=b0){ b0=g_t7_blits; bt=t; } if((bt && t-bt>=20) || t>=700) break; }
|
||||
g_t7_dark=1; shot(a); printf("peek %d ms\n", t); }
|
||||
#endif
|
||||
#endif
|
||||
else if(!strcmp(cmd,"i")){ uint8_t ic[10]; t7_get_icons(ic); printf("icons"); for(int i=0;i<10;i++) printf(" %d",ic[i]); printf("\n"); }
|
||||
else if(!strcmp(cmd,"s")) shot(a);
|
||||
else if(!strcmp(cmd,"t")) printf("time %02d:%02d:%02d day %d.%d\n", t7_ram_read(0x306),t7_ram_read(0x307),t7_ram_read(t7_rtc_sec_addr()),t7_ram_read(0x305),t7_ram_read(0x304));
|
||||
else if(!strcmp(cmd,"poke")){ t7_ram_write((uint16_t)strtol(a,0,16),(uint8_t)x); }
|
||||
else if(!strcmp(cmd,"d")){ FILE*o=fopen(a,"wb"); fwrite(g_wram,1,T7_WRAM_SIZE,o); fclose(o); }
|
||||
else if(!strcmp(cmd,"r")){ int a0=(int)strtol(a,0,16), m=x>0?(int)x:1; printf("ram %03x:",a0); for(int i=0;i<m;i++) printf(" %02x",t7_ram_read((uint16_t)(a0+i))); printf("\n"); }
|
||||
#ifdef T7_BLIT_CACHE
|
||||
else if(!strcmp(cmd,"bc")){ extern uint32_t g_bc_hit, g_bc_miss; printf("blit cache hit %u miss %u\n", g_bc_hit, g_bc_miss);
|
||||
#ifdef T7_BC_LOG
|
||||
{ extern void bc_print(void); bc_print(); }
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
else if(!strcmp(cmd,"q")) break; fflush(stdout); }
|
||||
return 0; }
|
||||
/* Host: boot the V7 ROM, press keys, save screenshots. hrun <rom> [figure]; stdin: p A|B|C [s] | w s | s file | q */
|
||||
#include "../src/core/t7.h"
|
||||
#include <stdio.h>
|
||||
#include "../src/core/t7_internal.h"
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
void figure_rom_set_active(const unsigned char* p, unsigned int n);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
#ifdef T7_STOP_DBG
|
||||
static long g_step; void t7_stop_dbg(int w){ static int n; if (getenv("SDBG") && n++ < 400) fprintf(stderr, "step %ld STOP 3007=%02x 3008=%02x keys=%x halted=%d irqmask=%02x%02x nmi=%02x\n", g_step, g_cpureg[7], g_cpureg[8], g_keys, g_t7_halted, g_cpureg[0x70], g_cpureg[0x71], g_cpureg[0x76]); (void)w; }
|
||||
#endif
|
||||
#ifdef T7_EEDBG
|
||||
static double g_now; void t7_eedbg(uint16_t a, uint8_t v){ static double last=-1; if (getenv("EEDBG") && g_now != last) { fprintf(stderr, "ee write at %.2f s: %03x=%02x\n", g_now, a, v); last = g_now; } }
|
||||
#endif
|
||||
static void frames(double s){ static int cyc; if(!cyc) cyc=getenv("CYC")?atoi(getenv("CYC")):40000; int n=(int)(s*100+0.5); for(int i=0;i<n;i++) { t7_step_cycles(cyc);
|
||||
#ifdef T7_EEDBG
|
||||
g_now += 0.01;
|
||||
#endif
|
||||
} }
|
||||
static void shot(const char *f){ uint8_t d[48*31], ic[10]; t7_get_display(d); t7_get_icons(ic);
|
||||
static const int pal[4]={0xE0,0xA0,0x60,0x20}; FILE*o=fopen(f,"wb"); fprintf(o,"P6 192 140 255\n");
|
||||
for(int y=0;y<140;y++) for(int x=0;x<192;x++){ int v=0xF0;
|
||||
if(y>=8&&y<132){ int yy=(y-8)/4, xx=x/4; if(yy<31) v=pal[d[yy*48+xx]]; }
|
||||
else { int k=x/(192/5)+(y>=132?5:0); v=ic[k]?pal[ic[k]]:0xF0; }
|
||||
fputc(v,o); fputc(v,o); fputc(v,o);} fclose(o); }
|
||||
int main(int c, char **v){ size_t n; unsigned char *rom=rd(v[1],&n); host_set_rom(rom,n);
|
||||
if(c>2){ size_t fn; unsigned char*f=rd(v[2],&fn); figure_rom_set_active(f,(unsigned)fn); t7_figure_set(1); }
|
||||
if (getenv("EE")) { size_t en; unsigned char *e=rd(getenv("EE"),&en); extern void persist_restore_page(int,const uint8_t*); for (int i=0;i<16 && (size_t)(i+1)*256<=en;i++) persist_restore_page(i,e+i*256); } /* EE=save: EEPROM from a file */
|
||||
if(!t7_init()){ printf("init failed\n"); return 1; }
|
||||
if (getenv("SND")) { extern void t7_snd_set_mode(int); t7_snd_set_mode(1); }
|
||||
#ifdef T7_JSR_HLE
|
||||
if (getenv("DARK")) g_t7_dark = 1; /* screen off as on the device */
|
||||
#endif
|
||||
char l[256]; while(fgets(l,sizeof l,stdin)){ char cmd[16],a[200]; double x=0; int k=sscanf(l,"%15s %199s %lf",cmd,a,&x); if(k<1) continue;
|
||||
if(!strcmp(cmd,"p")){ t7_set_buttons(a[0]=='A'?1:a[0]=='B'?2:4); frames(0.2); t7_set_buttons(0); frames(k>2?x:0.8); }
|
||||
else if(!strcmp(cmd,"w")) frames(atof(a));
|
||||
else if(!strcmp(cmd,"tl")){ /* tl <s>: tone list in 2 ms steps (hz x steps) */ extern uint32_t t7_snd_tone_hz(uint8_t*); uint32_t last=0xFFFFFFFF; int n=0; int m=(int)(atof(a)*500+0.5);
|
||||
for(int i=0;i<m;i++){ t7_step_cycles(8000); uint8_t lv; uint32_t hz=t7_snd_tone_hz(&lv); if(hz!=last){ if(n) printf("%u x%d\n",last,n); last=hz; n=0; } n++; } printf("%u x%d\nEND\n",last,n); }
|
||||
else if(!strcmp(cmd,"k")){ double g=0; sscanf(l,"%*s %*s %lf %lf",&x,&g); int m=a[0]=='A'?1:a[0]=='B'?2:4; /* k A hold gap: a quick press in 2 ms steps */
|
||||
t7_set_buttons(m); for(int i=0;i<(int)(x*500+0.5);i++) { t7_step_cycles(8000);
|
||||
#ifdef T7_STOP_DBG
|
||||
g_step++; if (getenv("TL")) fputc(g_t7_halted ? 'h' : 'r', stderr);
|
||||
#endif
|
||||
}
|
||||
#ifdef T7_STOP_DBG
|
||||
if (getenv("TL")) fputc('|', stderr);
|
||||
#endif
|
||||
t7_set_buttons(0); for(int i=0;i<(int)(g*500+0.5);i++) { t7_step_cycles(8000);
|
||||
#ifdef T7_STOP_DBG
|
||||
if (getenv("TL")) fputc(g_t7_halted ? 'H' : 'R', stderr);
|
||||
#endif
|
||||
}
|
||||
#ifdef T7_STOP_DBG
|
||||
if (getenv("TL")) fputc('\n', stderr);
|
||||
#endif
|
||||
}
|
||||
#ifdef T7_JSR_HLE
|
||||
else if(!strcmp(cmd,"dk")){ g_t7_dark=(uint8_t)atoi(a); } /* dk 1|0: screen off/on */
|
||||
#ifdef T7_WAKE_FRESH
|
||||
else if(!strcmp(cmd,"wake")){ extern uint32_t g_t7_blits; uint32_t b0=g_t7_blits, bt=0; int t=0; g_t7_dark=0; /* wake: on as T7_WAKE_FRESH (light after a drawn picture) */
|
||||
for(;;){ t7_step_cycles(8000); t+=2; if(g_t7_blits!=b0){ b0=g_t7_blits; bt=t; } if((bt && t-bt>=20) || t>=700) break; }
|
||||
printf("wake light after %d ms\n", t); }
|
||||
else if(!strcmp(cmd,"peek")){ extern uint32_t g_t7_blits; uint32_t b0=g_t7_blits, bt=0; int t=0; g_t7_dark=0; /* peek: one picture with the screen dark, then dark again */
|
||||
for(;;){ t7_step_cycles(8000); t+=2; if(g_t7_blits!=b0){ b0=g_t7_blits; bt=t; } if((bt && t-bt>=20) || t>=700) break; }
|
||||
g_t7_dark=1; shot(a); printf("peek %d ms\n", t); }
|
||||
#endif
|
||||
#endif
|
||||
else if(!strcmp(cmd,"i")){ uint8_t ic[10]; t7_get_icons(ic); printf("icons"); for(int i=0;i<10;i++) printf(" %d",ic[i]); printf("\n"); }
|
||||
else if(!strcmp(cmd,"s")) shot(a);
|
||||
else if(!strcmp(cmd,"t")) printf("time %02d:%02d:%02d day %d.%d\n", t7_ram_read(0x306),t7_ram_read(0x307),t7_ram_read(t7_rtc_sec_addr()),t7_ram_read(0x305),t7_ram_read(0x304));
|
||||
else if(!strcmp(cmd,"poke")){ t7_ram_write((uint16_t)strtol(a,0,16),(uint8_t)x); }
|
||||
else if(!strcmp(cmd,"d")){ FILE*o=fopen(a,"wb"); fwrite(g_wram,1,T7_WRAM_SIZE,o); fclose(o); }
|
||||
else if(!strcmp(cmd,"r")){ int a0=(int)strtol(a,0,16), m=x>0?(int)x:1; printf("ram %03x:",a0); for(int i=0;i<m;i++) printf(" %02x",t7_ram_read((uint16_t)(a0+i))); printf("\n"); }
|
||||
#ifdef T7_BLIT_CACHE
|
||||
else if(!strcmp(cmd,"bc")){ extern uint32_t g_bc_hit, g_bc_miss; printf("blit cache hit %u miss %u\n", g_bc_hit, g_bc_miss);
|
||||
#ifdef T7_BC_LOG
|
||||
{ extern void bc_print(void); bc_print(); }
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
else if(!strcmp(cmd,"q")) break; fflush(stdout); }
|
||||
return 0; }
|
||||
+15
-15
@@ -1,15 +1,15 @@
|
||||
/* PC histogram of the V7 firmware (host). pcprof <rom> <setup.txt-like keys file> <secs> */
|
||||
#include "../src/core/t7_internal.h"
|
||||
#include <stdio.h>
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
static unsigned cnt[65536];
|
||||
int main(int c,char**v){ size_t n; unsigned char *rm=rd(v[1],&n); host_set_rom(rm,n); if(!t7_init()) return 1;
|
||||
double secs=atof(v[2]); long total=(long)(secs*4000000), done=0; long ins=0;
|
||||
/* after 5 s, count */
|
||||
while(done<total){ uint32_t s=t7_step_cycles(4000); done+=s; }
|
||||
for(long k=0;k<(long)(2*4000000);){ uint16_t pc=g_cpu.pc; cnt[pc]++; ins++; uint32_t cy=t7_step_one(); if(!cy) cy=1; k+=cy;
|
||||
static uint32_t acc; acc+=cy; if(acc>=66666){acc-=66666; t7_fire_irq(10); t7_fire_nmi(6);} }
|
||||
printf("instr in 2 s: %ld (%.2f M/s)\n", ins, ins/2e6);
|
||||
for(int r=0;r<15;r++){ int b=0; for(int i=1;i<65536;i++) if(cnt[i]>cnt[b]) b=i; printf("%04x %u bank %d\n",b,cnt[b],g_rom_bank_id); cnt[b]=0; }
|
||||
}
|
||||
/* PC histogram of the V7 firmware (host). pcprof <rom> <setup.txt-like keys file> <secs> */
|
||||
#include "../src/core/t7_internal.h"
|
||||
#include <stdio.h>
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
static unsigned cnt[65536];
|
||||
int main(int c,char**v){ size_t n; unsigned char *rm=rd(v[1],&n); host_set_rom(rm,n); if(!t7_init()) return 1;
|
||||
double secs=atof(v[2]); long total=(long)(secs*4000000), done=0; long ins=0;
|
||||
/* after 5 s, count */
|
||||
while(done<total){ uint32_t s=t7_step_cycles(4000); done+=s; }
|
||||
for(long k=0;k<(long)(2*4000000);){ uint16_t pc=g_cpu.pc; cnt[pc]++; ins++; uint32_t cy=t7_step_one(); if(!cy) cy=1; k+=cy;
|
||||
static uint32_t acc; acc+=cy; if(acc>=66666){acc-=66666; t7_fire_irq(10); t7_fire_nmi(6);} }
|
||||
printf("instr in 2 s: %ld (%.2f M/s)\n", ins, ins/2e6);
|
||||
for(int r=0;r<15;r++){ int b=0; for(int i=1;i<65536;i++) if(cnt[i]>cnt[b]) b=i; printf("%04x %u bank %d\n",b,cnt[b],g_rom_bank_id); cnt[b]=0; }
|
||||
}
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
/* Same key script on t7_cpu_step and on t7_cpu_run (build twice, -DT7_FASTRUN): prints a hash of
|
||||
* the whole state after every 2 ms step; the two outputs must be equal. runcmp <rom> <script> */
|
||||
#include "../src/core/t7_internal.h"
|
||||
#include "../src/core/t7_sound.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
static uint32_t h(const uint8_t *p, int n, uint32_t s){ while(n--) s = s*16777619u ^ *p++; return s; }
|
||||
int main(int c,char**v){ size_t n; unsigned char*rm=rd(v[1],&n); host_set_rom(rm,n); if(!t7_init()) return 1;
|
||||
if (c>3) t7_snd_set_mode(1);
|
||||
FILE*f=fopen(v[2],"r"); char l[128]; long step=0;
|
||||
while(fgets(l,sizeof l,f)){ char k=0; double s=0; if(sscanf(l,"%c %lf",&k,&s)<2) continue;
|
||||
t7_set_buttons(k=='A'?1:k=='B'?2:k=='C'?4:0);
|
||||
int m=(int)(s*500+0.5);
|
||||
for(int i=0;i<m;i++){ t7_step_cycles(8000); uint8_t buf[4096]; uint32_t sz=t7_serialize_state(buf,sizeof buf);
|
||||
uint32_t hh=h(buf,sz,2166136261u); printf("%ld %08x pc=%04x a=%02x x=%02x y=%02x s=%02x w=%08x d=%08x r=%08x\n",step++,hh,g_cpu.pc,g_cpu.a,g_cpu.x,g_cpu.y,g_cpu.s,h(g_wram,0x600,1),h(g_dram,0x200,1),h(g_cpureg,256,1)); } }
|
||||
if (getenv("CLK")) { for (int i = 0x390; i < 0x3A0; i++) fprintf(stderr, "%02x ", g_wram[i]); fprintf(stderr, "\n"); }
|
||||
#if defined(T7_IDLE) || defined(T7_STOP)
|
||||
fprintf(stderr, "idle ok %u, skipped %u cycles of %ld\n", g_t7_idle_ok, g_t7_idle_cyc, step * 8000L);
|
||||
#endif
|
||||
return 0; }
|
||||
/* Same key script on t7_cpu_step and on t7_cpu_run (build twice, -DT7_FASTRUN): prints a hash of
|
||||
* the whole state after every 2 ms step; the two outputs must be equal. runcmp <rom> <script> */
|
||||
#include "../src/core/t7_internal.h"
|
||||
#include "../src/core/t7_sound.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
void host_set_rom(unsigned char *p, size_t n);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
static uint32_t h(const uint8_t *p, int n, uint32_t s){ while(n--) s = s*16777619u ^ *p++; return s; }
|
||||
int main(int c,char**v){ size_t n; unsigned char*rm=rd(v[1],&n); host_set_rom(rm,n); if(!t7_init()) return 1;
|
||||
if (c>3) t7_snd_set_mode(1);
|
||||
FILE*f=fopen(v[2],"r"); char l[128]; long step=0;
|
||||
while(fgets(l,sizeof l,f)){ char k=0; double s=0; if(sscanf(l,"%c %lf",&k,&s)<2) continue;
|
||||
t7_set_buttons(k=='A'?1:k=='B'?2:k=='C'?4:0);
|
||||
int m=(int)(s*500+0.5);
|
||||
for(int i=0;i<m;i++){ t7_step_cycles(8000); uint8_t buf[4096]; uint32_t sz=t7_serialize_state(buf,sizeof buf);
|
||||
uint32_t hh=h(buf,sz,2166136261u); printf("%ld %08x pc=%04x a=%02x x=%02x y=%02x s=%02x w=%08x d=%08x r=%08x\n",step++,hh,g_cpu.pc,g_cpu.a,g_cpu.x,g_cpu.y,g_cpu.s,h(g_wram,0x600,1),h(g_dram,0x200,1),h(g_cpureg,256,1)); } }
|
||||
if (getenv("CLK")) { for (int i = 0x390; i < 0x3A0; i++) fprintf(stderr, "%02x ", g_wram[i]); fprintf(stderr, "\n"); }
|
||||
#if defined(T7_IDLE) || defined(T7_STOP)
|
||||
fprintf(stderr, "idle ok %u, skipped %u cycles of %ld\n", g_t7_idle_ok, g_t7_idle_cyc, step * 8000L);
|
||||
#endif
|
||||
return 0; }
|
||||
+18
-18
@@ -1,18 +1,18 @@
|
||||
w 3
|
||||
p B 2
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p A 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
w 3
|
||||
p B 2
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p A 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.6
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
p B 0.8
|
||||
+13
-13
@@ -1,13 +1,13 @@
|
||||
#include "../src/core/t7_internal.h"
|
||||
#include <stdio.h>
|
||||
void host_set_rom(unsigned char *p, size_t n); uint8_t t7_dbg_p(void); uint32_t t7_cpu_run(uint32_t);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
int main(int c,char**v){ size_t n; unsigned char*rm=rd(v[1],&n); host_set_rom(rm,n); t7_init(); long N=atol(v[2]);
|
||||
for(long i=0;i<N;i++){
|
||||
#ifdef T7_FASTRUN
|
||||
uint32_t cy=t7_cpu_run(1);
|
||||
#else
|
||||
uint32_t cy=t7_cpu_step();
|
||||
#endif
|
||||
printf("%ld %04x %02x %02x %02x %02x %02x %u m48=%02x %02x\n",i,g_cpu.pc,g_cpu.a,g_cpu.x,g_cpu.y,g_cpu.s,t7_dbg_p(),cy,t7_read_page[0][0x48],t7_read_page[0][0x49]); }
|
||||
}
|
||||
#include "../src/core/t7_internal.h"
|
||||
#include <stdio.h>
|
||||
void host_set_rom(unsigned char *p, size_t n); uint8_t t7_dbg_p(void); uint32_t t7_cpu_run(uint32_t);
|
||||
static unsigned char *rd(const char *f, size_t *n){ FILE*x=fopen(f,"rb"); fseek(x,0,2); *n=ftell(x); fseek(x,0,0); unsigned char*p=malloc(*n); if(fread(p,1,*n,x)){} fclose(x); return p; }
|
||||
int main(int c,char**v){ size_t n; unsigned char*rm=rd(v[1],&n); host_set_rom(rm,n); t7_init(); long N=atol(v[2]);
|
||||
for(long i=0;i<N;i++){
|
||||
#ifdef T7_FASTRUN
|
||||
uint32_t cy=t7_cpu_run(1);
|
||||
#else
|
||||
uint32_t cy=t7_cpu_step();
|
||||
#endif
|
||||
printf("%ld %04x %02x %02x %02x %02x %02x %u m48=%02x %02x\n",i,g_cpu.pc,g_cpu.a,g_cpu.x,g_cpu.y,g_cpu.s,t7_dbg_p(),cy,t7_read_page[0][0x48],t7_read_page[0][0x49]); }
|
||||
}
|
||||
Reference in new issue
Block a user