mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-11 12:29:29 +00:00
showHelp(), -f3
This commit is contained in:
parent
d5a89b0837
commit
43e33f143c
|
@ -78,6 +78,7 @@ TODO:
|
||||||
- batariBasic: proper line numbers, listing, syntax highlighting
|
- batariBasic: proper line numbers, listing, syntax highlighting
|
||||||
- show player controls for each platform, allow touch support
|
- show player controls for each platform, allow touch support
|
||||||
- granular control over time scrubbing, show CPU state
|
- granular control over time scrubbing, show CPU state
|
||||||
|
- __MAIN__ for main C file
|
||||||
|
|
||||||
|
|
||||||
WEB WORKER FORMAT
|
WEB WORKER FORMAT
|
||||||
|
|
|
@ -114,6 +114,12 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||||
<li><a class="dropdown-item" href="?platform=verilog" id="item_platform_verilog">Verilog</a></li>
|
<li><a class="dropdown-item" href="?platform=verilog" id="item_platform_verilog">Verilog</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="dropdown dropdown-submenu">
|
||||||
|
<a tabindex="-1" href="#">Other</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="?platform=markdown" id="item_platform_markdown">Markdown</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,123 +1,140 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <cv.h>
|
#include <cv.h>
|
||||||
#include <cvu.h>
|
#include <cvu.h>
|
||||||
|
|
||||||
const uint8_t sprite[0x1][0x20] = {/*{w:16,h:16,remap:[4,0,1,2,3],brev:1}*/
|
// number of sprite patterns
|
||||||
{0xE0, 0xC0, 0xA0, 0x10, 0x0A, 0x04, 0x0B, 0x03, 0x03, 0x0B, 0x04, 0x0A, 0x10, 0xA0, 0xC0, 0xE0, 0x07, 0x03, 0x05, 0x08, 0x50, 0x20, 0xD0, 0xC0, 0xC0, 0xD0, 0x20, 0x50, 0x08, 0x05, 0x03, 0x07}
|
#define NUM_SPRITE_PATTERNS 1
|
||||||
};
|
|
||||||
|
|
||||||
/* VRAM map
|
// Sprite bitmap -- can edit with Edit Bitmap button
|
||||||
0x0000 - 0x17ff character pattern table
|
const uint8_t sprite_data[NUM_SPRITE_PATTERNS][32] = {/*{w:16,h:16,remap:[4,0,1,2,3],brev:1}*/
|
||||||
0x1800 - 0x1aff image table
|
{0xE0, 0xC0, 0xA0, 0x11, 0x0B, 0x05, 0x0B, 0x1F, 0x1F, 0x0F, 0x05, 0x0B, 0x11, 0xA0, 0xC0, 0xE0, 0x07, 0x03, 0x05, 0x88, 0xD0, 0xA0, 0xD0, 0xF8, 0xF8, 0xD0, 0xA0, 0xD0, 0x88, 0x05, 0x03, 0x07}
|
||||||
0x2000 - 0x37ff color table
|
};
|
||||||
0x3800 - 0x3bff sprite pattern table
|
|
||||||
0x3c00 - 0x3fff sprite attribute table
|
|
||||||
*/
|
|
||||||
|
|
||||||
const cv_vmemp IMAGE = 0x1800;
|
const cv_vmemp IMAGE = 0x1800;
|
||||||
const cv_vmemp SPRITES = 0x3c00;
|
const cv_vmemp SPRITES = 0x3c00;
|
||||||
const cv_vmemp SPRITE_PATTERNS = 0x3800;
|
const cv_vmemp SPRITE_PATTERNS = 0x3800;
|
||||||
|
|
||||||
volatile bool step; // Has to be volatile since it's modified in the NMI handler.
|
// Make this variable volatile since it's modified in the NMI handler.
|
||||||
|
volatile bool vblank;
|
||||||
|
|
||||||
void move_cursor(struct cvu_sprite *s)
|
// NMI handler routine.
|
||||||
{
|
void nmi(void) {
|
||||||
|
vblank = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for next VBLANK (next frame)
|
||||||
|
void waitvblank() {
|
||||||
|
vblank = false; // reset vblank flag
|
||||||
|
while(!vblank); // wait for the NMI handler to set this flag.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move sprite s with specified controller.
|
||||||
|
void move_cursor(struct cvu_sprite *s, int controller) {
|
||||||
int x, y;
|
int x, y;
|
||||||
struct cv_controller_state cs;
|
struct cv_controller_state cs;
|
||||||
|
|
||||||
cv_get_controller_state(&cs, 0); // Read the controller.
|
// Read the game controller state.
|
||||||
|
cv_get_controller_state(&cs, controller);
|
||||||
|
|
||||||
x = cvu_get_sprite_x(s);
|
// Copy the sprite X and Y coordinates to local variables.
|
||||||
y = cvu_get_sprite_y(s);
|
x = s->x;
|
||||||
|
y = s->y;
|
||||||
|
|
||||||
if(cs.joystick & CV_RIGHT) // Move cursor to the right by one pixel.
|
// Move one pixel in the direction the joystick is pointed.
|
||||||
x++;
|
if (cs.joystick & CV_RIGHT) x++;
|
||||||
else if(cs.joystick & CV_LEFT) // Move the cursor to the left by one pixel.
|
if (cs.joystick & CV_LEFT) x--;
|
||||||
x--;
|
if (cs.joystick & CV_DOWN) y++;
|
||||||
if(cs.joystick & CV_DOWN) // Move the cursor down by one pixel.
|
if (cs.joystick & CV_UP) y--;
|
||||||
y++;
|
|
||||||
else if(cs.joystick & CV_UP) // Move the cursor up by one pixel.
|
|
||||||
y--;
|
|
||||||
|
|
||||||
// Move cursor by how much the wheels on the super action controllers or the ball in the roller controller indicate.
|
// Move cursor by the spinner controllers (if present)
|
||||||
x += cvu_get_spinner(0);
|
x += cvu_get_spinner(0);
|
||||||
y += cvu_get_spinner(1);
|
y += cvu_get_spinner(1);
|
||||||
|
|
||||||
// Limit to area.
|
// Make sure cursor doesn't leave the screen.
|
||||||
if(x > 239)
|
if(x < 0) x = 0;
|
||||||
x = 239;
|
if(x > 239) x = 239;
|
||||||
else if(x < 0)
|
if(y < 0) y = 0;
|
||||||
x = 0;
|
if(y > 152) y = 152;
|
||||||
if(y > 152)
|
|
||||||
y = 152;
|
|
||||||
else if(y < 0)
|
|
||||||
y = 0;
|
|
||||||
|
|
||||||
cvu_set_sprite_xy(s, x, y);
|
// Update the cursor struct in CPU RAM.
|
||||||
|
s->x = x;
|
||||||
|
s->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nmi(void)
|
// Set all sprites offscreen.
|
||||||
{
|
void set_sprites_offscreen() {
|
||||||
step = true;
|
struct cvu_sprite s;
|
||||||
cv_set_colors(0, CV_COLOR_YELLOW);
|
s.x = 0;
|
||||||
}
|
s.y = 208; // set offscreen
|
||||||
|
s.name = 0;
|
||||||
void waitvblank() {
|
s.tag = 0;
|
||||||
step = false;
|
for (int i=0; i<32; i++) {
|
||||||
while(!step); // Wait until the NMI handler sets step to true.
|
cvu_set_sprite(SPRITES, i, &s); // set sprite in Video RAM
|
||||||
cv_set_colors(0, CV_COLOR_RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
void shuffle_sprites(struct cvu_sprite* s) {
|
|
||||||
int i;
|
|
||||||
for (i=1; i<32; i++) {
|
|
||||||
s->x = i*16;
|
|
||||||
s->y = i*8;
|
|
||||||
cvu_set_sprite(SPRITES, i, s); // Update the cursor on the screen.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setup_vdp() {
|
||||||
|
cv_set_screen_active(false); // Switch screen off.
|
||||||
|
cv_set_color_table(0x3fff);
|
||||||
|
cv_set_character_pattern_t(0x1fff);
|
||||||
|
cv_set_image_table(IMAGE);
|
||||||
|
cv_set_sprite_pattern_table(SPRITE_PATTERNS);
|
||||||
|
cv_set_sprite_attribute_table(SPRITES);
|
||||||
|
cv_set_screen_mode(CV_SCREENMODE_BITMAP); // Doesn't really matter much here. We only need a screen mode that supports sprites.
|
||||||
|
cvu_vmemset(0, 0, 0x4000); // clear Video RAM
|
||||||
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
struct cvu_sprite s; // The sprite used for the player cursor.
|
struct cvu_sprite s; // The sprite used for the player cursor.
|
||||||
struct cvu_sprite s2; // The sprite used for the target cursor.
|
struct cvu_sprite s2; // The sprite used for the target cursor.
|
||||||
|
|
||||||
cv_set_screen_active(false); // Switch screen off.
|
setup_vdp();
|
||||||
|
|
||||||
cv_set_color_table(0x3fff);
|
cv_set_sprite_magnification(false); // no sprite magnification
|
||||||
cv_set_character_pattern_t(0x1fff);
|
|
||||||
cv_set_image_table(IMAGE);
|
|
||||||
cv_set_sprite_pattern_table(SPRITE_PATTERNS);
|
|
||||||
cv_set_sprite_attribute_table(SPRITES);
|
|
||||||
cv_set_screen_mode(CV_SCREENMODE_BITMAP); // Doesn't really matter much here. We only need a screen mode that supports sprites.
|
|
||||||
cvu_vmemset(0, 0, 0x4000);
|
|
||||||
|
|
||||||
cv_set_sprite_magnification(false);
|
|
||||||
cv_set_sprite_big(true); // 16x16 pixel sprites.
|
cv_set_sprite_big(true); // 16x16 pixel sprites.
|
||||||
|
|
||||||
cvu_set_sprite_x(&s, 60); // Set initial cursor position.
|
// Set all sprites offscreen initially.
|
||||||
cvu_set_sprite_y(&s, 60); // Set initial cursor position.
|
// This ensures they won't set the collision bit.
|
||||||
cvu_set_sprite_color(&s, CV_COLOR_WHITE);
|
set_sprites_offscreen();
|
||||||
cvu_set_sprite_color(&s2, CV_COLOR_GREEN);
|
|
||||||
|
// Set attributes for sprite 0.
|
||||||
|
s.x = 60;
|
||||||
|
s.y = 60;
|
||||||
s.name = 0; // Use sprite pattern number 0.
|
s.name = 0; // Use sprite pattern number 0.
|
||||||
|
cvu_set_sprite_color(&s, CV_COLOR_WHITE);
|
||||||
|
// Set attributes for sprite 1.
|
||||||
|
s2.x = 120;
|
||||||
|
s2.y = 60;
|
||||||
s2.name = 0;
|
s2.name = 0;
|
||||||
cvu_memtovmemcpy(SPRITE_PATTERNS, sprite, 0x20); // Copy sprite pattern number 0 to graphics memory.
|
cvu_set_sprite_color(&s2, CV_COLOR_YELLOW);
|
||||||
|
// Copy sprite pattern number 0 to graphics memory.
|
||||||
|
// Each sprite takes up 16*2 = 32 bytes.
|
||||||
|
cvu_memtovmemcpy(SPRITE_PATTERNS,
|
||||||
|
sprite_data,
|
||||||
|
NUM_SPRITE_PATTERNS*32);
|
||||||
|
|
||||||
cv_set_screen_active(true); // Switch screen on.
|
// Turn on video display.
|
||||||
|
cv_set_screen_active(true);
|
||||||
|
|
||||||
shuffle_sprites(&s2);
|
// Set NMI handler so we can detect VBLANK.
|
||||||
|
|
||||||
cv_set_vint_handler(nmi);
|
cv_set_vint_handler(nmi);
|
||||||
|
// Set background color
|
||||||
|
cv_set_colors(0, CV_COLOR_BLUE);
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
cv_set_colors(0, 0);
|
// Wait for VBLANK (next frame).
|
||||||
waitvblank();
|
waitvblank();
|
||||||
cv_set_colors(0, CV_COLOR_LIGHT_GREEN);
|
// Turn sprite 0 red if there was a collision last frame.
|
||||||
cvu_set_sprite_color(&s, cv_get_sprite_collission() ?
|
cvu_set_sprite_color(&s, cv_get_sprite_collission() ?
|
||||||
CV_COLOR_RED : CV_COLOR_WHITE);
|
CV_COLOR_RED : CV_COLOR_WHITE);
|
||||||
move_cursor(&s);
|
// Move both cursors by their corresponding joystick.
|
||||||
cvu_set_sprite(SPRITES, 0, &s); // Update the cursor on the screen.
|
move_cursor(&s, 0);
|
||||||
|
move_cursor(&s2, 1);
|
||||||
|
// Update VRAM with new sprite records.
|
||||||
|
cvu_set_sprite(SPRITES, 0, &s);
|
||||||
|
cvu_set_sprite(SPRITES, 1, &s2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ export interface Platform {
|
||||||
|
|
||||||
setRecorder?(recorder : EmuRecorder) : void;
|
setRecorder?(recorder : EmuRecorder) : void;
|
||||||
advance?(novideo? : boolean) : void;
|
advance?(novideo? : boolean) : void;
|
||||||
|
showHelp?(tool:string, ident?:string) : void;
|
||||||
|
|
||||||
debugSymbols? : DebugSymbols;
|
debugSymbols? : DebugSymbols;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ const _ColecoVisionPlatform = function(mainElement) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
vdp = new TMS9918A(video.canvas, cru, false);
|
vdp = new TMS9918A(video.canvas, cru, true); // true = 4 sprites/line
|
||||||
setKeyboardFromMap(video, inputs, COLECOVISION_KEYCODE_MAP);
|
setKeyboardFromMap(video, inputs, COLECOVISION_KEYCODE_MAP);
|
||||||
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,9 @@ class MarkdownPlatform implements Platform {
|
||||||
{id:'hello.md', name:'Hello'},
|
{id:'hello.md', name:'Hello'},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
showHelp() {
|
||||||
|
window.open("https://github.com/showdownjs/showdown/wiki/Showdown's-Markdown-syntax", "_help");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PLATFORMS['markdown'] = MarkdownPlatform;
|
PLATFORMS['markdown'] = MarkdownPlatform;
|
||||||
|
|
|
@ -269,7 +269,16 @@ class VCSPlatform extends BasePlatform {
|
||||||
disassemble(pc:number, read:(addr:number)=>number) : DisasmLine {
|
disassemble(pc:number, read:(addr:number)=>number) : DisasmLine {
|
||||||
return disassemble6502(pc, read(pc), read(pc+1), read(pc+2));
|
return disassemble6502(pc, read(pc), read(pc+1), read(pc+2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showHelp(tool:string, ident:string) {
|
||||||
|
if (tool == 'bataribasic')
|
||||||
|
window.open("help/bataribasic/manual.html", "_help");
|
||||||
|
else
|
||||||
|
window.open("https://alienbill.com/2600/101/docs/stella.html", "_help"); // TODO
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: mixin for Base6502Platform?
|
// TODO: mixin for Base6502Platform?
|
||||||
|
|
||||||
function nonegstr(n) {
|
function nonegstr(n) {
|
||||||
|
|
|
@ -876,8 +876,10 @@ function _toggleRecording() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _lookupHelp() {
|
function _lookupHelp() {
|
||||||
// TODO
|
if (platform.showHelp) {
|
||||||
window.open("help/bataribasic/manual.html", "_help");
|
let tool = platform.getToolForFilename(main_file_id);
|
||||||
|
platform.showHelp(tool); // TODO: tool, identifier
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDebugControls(){
|
function setupDebugControls(){
|
||||||
|
@ -948,7 +950,7 @@ function setupDebugControls(){
|
||||||
$("#dbg_slowest").click(_slowestFrameRate);
|
$("#dbg_slowest").click(_slowestFrameRate);
|
||||||
$("#dbg_fastest").click(_fastestFrameRate);
|
$("#dbg_fastest").click(_fastestFrameRate);
|
||||||
}
|
}
|
||||||
if (platform.getToolForFilename(main_file_id) == 'bataribasic') {
|
if (platform.showHelp) {
|
||||||
$("#dbg_help").show().click(_lookupHelp);
|
$("#dbg_help").show().click(_lookupHelp);
|
||||||
}
|
}
|
||||||
updateDebugWindows();
|
updateDebugWindows();
|
||||||
|
|
|
@ -649,7 +649,7 @@ function assembleDASM(step:BuildStep) {
|
||||||
var binpath = step.prefix+'.bin';
|
var binpath = step.prefix+'.bin';
|
||||||
var lstpath = step.prefix+'.lst';
|
var lstpath = step.prefix+'.lst';
|
||||||
var sympath = step.prefix+'.sym';
|
var sympath = step.prefix+'.sym';
|
||||||
execMain(step, Module, [step.path,
|
execMain(step, Module, [step.path, '-f3',
|
||||||
"-l"+lstpath,
|
"-l"+lstpath,
|
||||||
"-o"+binpath,
|
"-o"+binpath,
|
||||||
"-s"+sympath ]);
|
"-s"+sympath ]);
|
||||||
|
@ -701,7 +701,7 @@ function assembleDASM(step:BuildStep) {
|
||||||
lst.lines = [];
|
lst.lines = [];
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
output:aout.slice(2),
|
output:aout,
|
||||||
listings:listings,
|
listings:listings,
|
||||||
errors:errors,
|
errors:errors,
|
||||||
symbolmap:symbolmap,
|
symbolmap:symbolmap,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user