Skip to content

Commit

Permalink
remote: updates for multiple linked files, c64 samples
Browse files Browse the repository at this point in the history
  • Loading branch information
sehugg committed Nov 5, 2023
1 parent 99f7ff4 commit f18365c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ npm run build

To use GitHub integration locally, download the Firebase config file, e.g. https://8bitworkshop.com/v[version]/config.js

### Start Server
### Start Local Web Server

Start a web server on http://localhost:8000/ while TypeScript compiles in the background:

Expand Down Expand Up @@ -69,6 +69,7 @@ The IDE uses custom forks for many of these, found at https://github.com/sehugg?
* http://www.twitchasylum.com/jsvecx/
* https://github.com/curiousdannii/ifvms.js/
* https://6502ts.github.io/typedoc/stellerator-embedded/
* https://github.com/yhzmr442/jspce

### Compilers

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"build": "make prepare",
"test": "npm run test-node",
"tsbuild": "tsc --build tsconfig.json",
"esbuild": "npm run esbuild-worker && npm run esbuild-ui",
"esbuild": "npm run esbuild-worker && npm run esbuild-ui && npm run esbuild-server",
"esbuild-clean": "rm -f ./gen/*.*",
"esbuild-server": "esbuild src/worker/server/server.ts --platform=node --bundle --sourcemap --target=es2020 --outfile=./gen/server/server.js",
"esbuild-worker": "esbuild src/worker/workermain.ts --bundle --sourcemap --target=es2017 --outfile=./gen/worker/bundle.js",
Expand Down
6 changes: 2 additions & 4 deletions presets/c64/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ void raster_wait(byte line) {
while (VIC.rasterline < line) ;
}

void wait_vblank(void) {
raster_wait(255);
}

static byte VIC_BANK_PAGE[4] = {
0xc0, 0x80, 0x40, 0x00
};
Expand All @@ -21,8 +17,10 @@ char* get_screen_memory() {
return ((VIC.addr & 0xf0) << 6) + get_vic_bank_start();
}

#ifdef __CC65__
char __fastcall__ poll_keyboard() {
asm("jmp $f142");
return __A__;
}
#endif

16 changes: 15 additions & 1 deletion presets/c64/common.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#ifndef _COMMON_H
#define _COMMON_H

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <peekpoke.h>
#include <string.h>
#include <c64.h>

#ifdef __CC65__
#include <conio.h>
#include <joystick.h>
#endif

typedef uint8_t byte; // 8-bit unsigned
typedef int8_t sbyte; // 8-bit signed
Expand Down Expand Up @@ -74,7 +77,18 @@ char* get_vic_bank_start();
// get current screen memory address
char* get_screen_memory();

#ifdef __CC65__
// return key in buffer, or 0 if none (BIOS call)
char __fastcall__ poll_keyboard();
#endif

#ifndef __CC65__
inline void clrscr() {
__asm__ volatile ("jsr $E544" : : : "a","x","y"); // regs clobbered
}
inline void waitvsync() {
raster_wait(255);
}
#endif

#endif
3 changes: 2 additions & 1 deletion presets/c64/sprite_collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void iterate_game(void) {
collide_sprites(spr_coll);
}

void main(void) {
int main(void) {

clrscr();
VIC.bordercolor = 0;
Expand All @@ -117,5 +117,6 @@ void main(void) {
while (1) {
iterate_game();
}
return 0;
}

7 changes: 3 additions & 4 deletions presets/c64/sprites.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ void sprite_clear(void) {

void sprite_update(byte* screenmem) {
memcpy(screenmem + 0x3f8, sprshad.spr_shapes, 8);
memcpy(VIC.spr_pos, sprshad.spr_pos, 16);
memcpy(VIC.spr_color, sprshad.spr_color, 8);
memcpy((void*)VIC.spr_pos, sprshad.spr_pos, 16);
memcpy((void*)VIC.spr_color, sprshad.spr_color, 8);
VIC.spr_ena = sprshad.spr_ena;
VIC.spr_hi_x = sprshad.spr_hi_x;
VIC.spr_exp_x = sprshad.spr_exp_x;
Expand Down Expand Up @@ -63,7 +63,6 @@ byte sprite_get_closest_collision(byte i, byte spr_coll) {
}
}
}
} else {
return 0xff;
}
return 0xff;
}
3 changes: 2 additions & 1 deletion src/ide/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ export class CodeProject {
msg.updates.push({path:mainfilename, data:maintext});
this.filename2path[mainfilename] = this.mainPath;
for (var dep of depends) {
if (!dep.link) {
// remote tools send both includes and linked files in one build step
if (!dep.link || this.remoteTool) {
msg.updates.push({path:dep.filename, data:dep.data});
depfiles.push(dep.filename);
}
Expand Down
19 changes: 14 additions & 5 deletions src/worker/server/buildenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { parseObjDumpListing, parseObjDumpSymbolTable } from './clang';
const LLVM_MOS_TOOL: ServerBuildTool = {
name: 'llvm-mos',
version: '',
extensions: ['.c'],
extensions: ['.c', '.cpp', '.s'],
archs: ['6502'],
platforms: ['atari8', 'c64', 'nes'],
platforms: ['atari8', 'c64', 'nes', 'pce', 'vcs'],
platform_configs: {
default: {
binpath: 'llvm-mos/bin',
Expand All @@ -27,13 +27,19 @@ const LLVM_MOS_TOOL: ServerBuildTool = {
},
c64: {
command: 'mos-c64-clang',
libargs: ['-D', '__C64__']
},
atari8: {
command: 'mos-atari8-clang',
libargs: ['-D', '__ATARI__']
},
nes: {
command: 'mos-nes-nrom-clang', // TODO
libargs: ['-lneslib']
libargs: ['-lneslib', '-lfamitone2']
},
pce: {
command: 'mos-pce-clang', // TODO
libargs: ['-lpce', '-D', '__PCE__']
},
}
}
Expand Down Expand Up @@ -127,8 +133,11 @@ export class ServerBuildEnv {
let infiles = [];
for (let i = 0; i < step.files.length; i++) {
let f = step.files[i];
if (f.endsWith(this.tool.extensions[0])) {
infiles.push(path.join(this.sessionDir, f));
for (let ext of this.tool.extensions) {
if (f.endsWith(ext)) {
infiles.push(path.join(this.sessionDir, f));
break;
}
}
}
for (let i = 0; i < args.length; i++) {
Expand Down
11 changes: 11 additions & 0 deletions src/worker/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ import cors from 'cors';
import { WorkerBuildStep, WorkerFileUpdate } from '../../common/workertypes';
import { ServerBuildEnv, TOOLS, findBestTool } from './buildenv';

/*
## Tool Server (not yet used)
```sh
npm run server
xattr -dr com.apple.quarantine llvm-mos/bin/* # macOS only
curl http://localhost:3009/test
go to: http://localhost:8000/?platform=c64&file=hello.c&tool=llvm-mos
```
*/

////////////////////

const app = express();
Expand Down
1 change: 1 addition & 0 deletions src/worker/tools/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const REMOTE_URL = "http://localhost:3009/build";
// create random UID
const sessionID = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);

// TODO: #include links but #link doesnt link
export async function buildRemote(step: BuildStep): Promise<BuildStepResult> {
gatherFiles(step); // TODO?
var binpath = "a.out"; // TODO?
Expand Down

0 comments on commit f18365c

Please sign in to comment.