cmoc: fixed error msgs, threed.c
This commit is contained in:
parent
c1cbb51c71
commit
74bfb04dd6
|
@ -175,6 +175,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
|||
<!--<li><a class="dropdown-item" href="?platform=sms-sg1000-libcv">Sega SG-1000</a></li>-->
|
||||
<li><a class="dropdown-item" href="?platform=sms-sms-libcv">Sega Master System</a></li>
|
||||
<li><a class="dropdown-item" href="?platform=atari7800">Atari 7800</a></li>
|
||||
<!--<li><a class="dropdown-item" href="?platform=vectrex">Vectrex</a></li>-->
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
#pragma vx_copyright "2020"
|
||||
#pragma vx_title_pos -100, -80
|
||||
#pragma vx_title_size -8, 80
|
||||
#pragma vx_title "CONTROLS TEST"
|
||||
#pragma vx_music vx_music_1
|
||||
|
||||
#include "vectrex.h"
|
||||
#include "bios.h"
|
||||
|
||||
// http://www.playvectrex.com/designit/chrissalo/joystick.htm
|
||||
|
||||
const char rom_text[] = "JOYSTICKS:";
|
||||
|
||||
int main()
|
||||
{
|
||||
char j1t[] = { '1', ':', '_', '_', '_', '_', 0x00 };
|
||||
char btn1[] = { '1', '2', '3', '4', 0x00 };
|
||||
char j2t[] = { '2', ':', '_', '_', '_', '_', 0x00 };
|
||||
char btn2[] = { '1', '2', '3', '4', 0x00 };
|
||||
|
||||
uint8_t i, j1, j2, btns;
|
||||
|
||||
while(1)
|
||||
{
|
||||
wait_retrace();
|
||||
|
||||
j1 = read_joystick(1);
|
||||
j2 = read_joystick(2);
|
||||
btns = read_buttons(); // momentary
|
||||
btns = *((byte*)0xc80f); // persistent
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
j1t[2+i] = (j1 & (1<<i)) ? 'X' : '_';
|
||||
j2t[2+i] = (j2 & (1<<i)) ? 'X' : '_';
|
||||
}
|
||||
|
||||
btn1[0] = (btns & JOY1_BTN1_MASK) ? 'X' : '1';
|
||||
btn1[1] = (btns & JOY1_BTN2_MASK) ? 'X' : '2';
|
||||
btn1[2] = (btns & JOY1_BTN3_MASK) ? 'X' : '3';
|
||||
btn1[3] = (btns & JOY1_BTN4_MASK) ? 'X' : '4';
|
||||
btn2[0] = (btns & JOY2_BTN1_MASK) ? 'X' : '1';
|
||||
btn2[1] = (btns & JOY2_BTN2_MASK) ? 'X' : '2';
|
||||
btn2[2] = (btns & JOY2_BTN3_MASK) ? 'X' : '3';
|
||||
btn2[3] = (btns & JOY2_BTN4_MASK) ? 'X' : '4';
|
||||
|
||||
intensity(0x7f);
|
||||
print_str_c( 0x10, -0x50, (char*)rom_text);
|
||||
print_str_c(-0x10, -0x50, j1t);
|
||||
print_str_c(-0x20, -0x40, btn1);
|
||||
print_str_c(-0x30, -0x50, j2t);
|
||||
print_str_c(-0x40, -0x40, btn2);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#pragma vx_copyright "2020"
|
||||
#pragma vx_title_pos -100, -80
|
||||
#pragma vx_title_size -8, 80
|
||||
#pragma vx_title "GAME TITLE"
|
||||
#pragma vx_music vx_music_1
|
||||
|
||||
#include "vectrex.h"
|
||||
#include "bios.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
wait_retrace();
|
||||
intensity(0x7f);
|
||||
print_str_c( 0x10, -0x50, (char*)"HELLO WORLD!" );
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
;***************************************************************************
|
||||
; DEFINE SECTION
|
||||
;***************************************************************************
|
||||
Intensity_5F EQU $F2A5 ; BIOS Intensity routine
|
||||
Print_Str_d EQU $F37A ; BIOS print routine
|
||||
Wait_Recal EQU $F192 ; BIOS recalibration
|
||||
music1 EQU $FF8F ; address of a (BIOS ROM)
|
||||
; music
|
||||
; start of vectrex memory with cartridge name...
|
||||
ORG 0
|
||||
;***************************************************************************
|
||||
; HEADER SECTION
|
||||
;***************************************************************************
|
||||
FCC "g GCE 2020"
|
||||
DB $80 ; 'g' is copyright sign
|
||||
DW music1 ; music from the rom
|
||||
DB $F8
|
||||
DB $50
|
||||
DB $20
|
||||
DB -$56 ; height, width, rel y, rel x
|
||||
; (from 0,0)
|
||||
FCC "GAME TITLE"
|
||||
DB $80 ; some game information,
|
||||
; ending with $80
|
||||
DB 0 ; end of game header
|
||||
;***************************************************************************
|
||||
; CODE SECTION
|
||||
;***************************************************************************
|
||||
; here the cartridge program starts off
|
||||
main:
|
||||
JSR Wait_Recal ; Vectrex BIOS recalibration
|
||||
JSR Intensity_5F ; Sets the intensity of the
|
||||
; vector beam to $5f
|
||||
LDU #hello ; address of string
|
||||
LDA #$10 ; Text position relative Y
|
||||
LDB #-$50 ; Text position relative X
|
||||
JSR Print_Str_d ; Vectrex BIOS print routine
|
||||
BRA main ; and repeat forever
|
||||
;***************************************************************************
|
||||
; DATA SECTION
|
||||
;***************************************************************************
|
||||
hello:
|
||||
FCC "HELLO WORLD" ; only capital letters
|
||||
DB $80 ; $80 is end of string
|
||||
;***************************************************************************
|
||||
END main
|
||||
;***************************************************************************
|
|
@ -0,0 +1,173 @@
|
|||
|
||||
#pragma vx_copyright "2020"
|
||||
#pragma vx_title_pos -100, -80
|
||||
#pragma vx_title_size -8, 80
|
||||
#pragma vx_title "CMOC ROTATE"
|
||||
#pragma vx_music vx_music_1
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "bios.h"
|
||||
|
||||
char rectangle[10] = {
|
||||
// These are relative coordinates.
|
||||
50, 0,
|
||||
0, 50,
|
||||
-50, 0,
|
||||
0, -50,
|
||||
// We also take the middle point of the rectangle which we move to before drawing.
|
||||
-25, -25
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
sbyte m[3][3];
|
||||
} Matrix;
|
||||
|
||||
typedef struct {
|
||||
sbyte x,y,z;
|
||||
} Vector8;
|
||||
|
||||
typedef struct {
|
||||
int x,y,z;
|
||||
} Vector16;
|
||||
|
||||
typedef struct {
|
||||
byte numverts;
|
||||
const Vector8* verts; // array of vertices
|
||||
const sbyte* edges; // array of vertex indices (edges)
|
||||
} Wireframe;
|
||||
|
||||
const Matrix IDENTITY = {{{127,0,0},{0,127,0},{0,0,127}}};
|
||||
|
||||
void mat_identity(Matrix* m) {
|
||||
*m = IDENTITY;
|
||||
}
|
||||
|
||||
void vec_mat_transform(Vector16* dest, const Vector8* v, const Matrix* m) {
|
||||
byte i;
|
||||
int* result = &dest->x;
|
||||
const sbyte* mval = &m->m[0][0];
|
||||
for (i=0; i<3; i++) {
|
||||
int sum = 0;
|
||||
sum += (int)*mval++ * v->x;
|
||||
sum += (int)*mval++ * v->y;
|
||||
sum += (int)*mval++ * v->z;
|
||||
*result++ = sum;
|
||||
}
|
||||
}
|
||||
|
||||
const sbyte sintbl[64] = {
|
||||
0, 3, 6, 9, 12, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46,
|
||||
49, 51, 54, 57, 60, 63, 65, 68, 71, 73, 76, 78, 81, 83, 85, 88,
|
||||
90, 92, 94, 96, 98, 100, 102, 104, 106, 107, 109, 111, 112, 113, 115, 116,
|
||||
117, 118, 120, 121, 122, 122, 123, 124, 125, 125, 126, 126, 126, 127, 127, 127,
|
||||
};
|
||||
|
||||
sbyte isin(byte x0) {
|
||||
byte x = x0;
|
||||
if (x0 & 0x40) x = 127-x;
|
||||
if (x0 & 0x80) {
|
||||
return -sintbl[x-128];
|
||||
} else {
|
||||
return sintbl[x];
|
||||
}
|
||||
}
|
||||
|
||||
sbyte icos(byte x) {
|
||||
return isin(x+64);
|
||||
}
|
||||
|
||||
void mat_rotate(Matrix* m, byte axis, byte angle) {
|
||||
sbyte sin = isin(angle);
|
||||
sbyte cos = icos(angle);
|
||||
mat_identity(m);
|
||||
switch (axis) {
|
||||
case 0:
|
||||
m->m[1][1] = cos;
|
||||
m->m[2][1] = sin;
|
||||
m->m[1][2] = -sin;
|
||||
m->m[2][2] = cos;
|
||||
break;
|
||||
case 1:
|
||||
m->m[2][2] = cos;
|
||||
m->m[0][2] = sin;
|
||||
m->m[2][0] = -sin;
|
||||
m->m[0][0] = cos;
|
||||
break;
|
||||
case 2:
|
||||
m->m[0][0] = cos;
|
||||
m->m[1][0] = sin;
|
||||
m->m[0][1] = -sin;
|
||||
m->m[1][1] = cos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const Vector8 tetra_v[] = { {0,-86,86},{86,86,86},{-86,86,86},{0,0,-86} };
|
||||
const char tetra_e[] = { 0, 1, 2, 0, 3, 1, -1, 3, 2, -2 };
|
||||
const Wireframe tetra = { 4, tetra_v, tetra_e };
|
||||
|
||||
void xform_vertices(Vector16* dest, const Vector8* src, const Matrix* m, byte nv) {
|
||||
byte i;
|
||||
for (i=0; i<nv; i++) {
|
||||
vec_mat_transform(dest++, src++, m);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_wireframe(const Wireframe* wf, Vector16* scrnverts) {
|
||||
const char* e = wf->edges;
|
||||
byte bright = 0;
|
||||
int x1 = 0;
|
||||
int y1 = 0;
|
||||
do {
|
||||
sbyte i = *e++;
|
||||
if (i == -1)
|
||||
bright = 0;
|
||||
else if (i == -2)
|
||||
break;
|
||||
else {
|
||||
int x2,y2;
|
||||
x2 = scrnverts[i].x >> 8;
|
||||
y2 = scrnverts[i].y >> 8;
|
||||
if (bright == 0)
|
||||
move((char)(x2-x1), (char)(y2-y1));
|
||||
else
|
||||
line((char)(x2-x1), (char)(y2-y1));
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
bright = 2;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void draw_wireframe_ortho(const Wireframe* wf, const Matrix* m) {
|
||||
Vector16 scrnverts[16];
|
||||
xform_vertices(scrnverts, wf->verts, m, wf->numverts);
|
||||
draw_wireframe(wf, scrnverts);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
word frame = 0;
|
||||
Matrix m;
|
||||
|
||||
int main()
|
||||
{
|
||||
sbyte x,y;
|
||||
mat_identity(&m);
|
||||
while(1)
|
||||
{
|
||||
x = isin((byte)frame)>>1;
|
||||
y = icos((byte)frame)>>1;
|
||||
wait_retrace();
|
||||
intensity(0x1f);
|
||||
// draw radar line
|
||||
move(0,0);
|
||||
line(x,y);
|
||||
line(-x,-y);
|
||||
// draw 3d shape
|
||||
mat_rotate(&m, (byte)(frame>>8)&3, (byte)frame);
|
||||
draw_wireframe_ortho(&tetra, &m);
|
||||
frame++;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -477,6 +477,10 @@ class JSNESPlatform extends Base6502Platform implements Platform, Probeable {
|
|||
{name:'APU Registers',start:0x4000,last:0x4020,size:0x2000,type:'io'},
|
||||
{name:'Cartridge RAM',start:0x6000,size:0x2000,type:'ram'},
|
||||
] } };
|
||||
|
||||
showHelp(tool:string, ident:string) {
|
||||
window.open("https://8bitworkshop.com/blog/platforms/nintendo-nes.md.html", "_help"); // TODO
|
||||
}
|
||||
}
|
||||
|
||||
/// MAME support
|
||||
|
|
|
@ -303,7 +303,7 @@ class VCSPlatform extends BasePlatform {
|
|||
if (tool == 'bataribasic')
|
||||
window.open("help/bataribasic/manual.html", "_help");
|
||||
else
|
||||
window.open("https://alienbill.com/2600/101/docs/stella.html", "_help"); // TODO
|
||||
window.open("https://8bitworkshop.com/blog/platforms/atari-2600-vcs.md.html", "_help"); // TODO
|
||||
}
|
||||
|
||||
getMemoryMap = function() { return {main:[
|
||||
|
|
|
@ -17,6 +17,8 @@ import { NullProbe, Probeable, ProbeAll } from "../common/devices";
|
|||
var VECTREX_PRESETS = [
|
||||
{ id: 'hello.xasm', name: 'Hello World (ASM)' },
|
||||
{ id: 'hello.c', name: 'Hello World (CMOC)' },
|
||||
{ id: 'joystick.c', name: 'Joystick Test (CMOC)' },
|
||||
{ id: 'threed.c', name: '3D Transformations (CMOC)' },
|
||||
]
|
||||
|
||||
// TODO: player 2
|
||||
|
|
|
@ -2074,7 +2074,7 @@ function compileCMOC(step:BuildStep) {
|
|||
loadNative("cmoc");
|
||||
var params = step.params;
|
||||
// stderr
|
||||
var re_err1 = /^([^:]*):(\d+): (.+)$/;
|
||||
var re_err1 = /^[/]*([^:]*):(\d+): (.+)$/;
|
||||
var errors : WorkerError[] = [];
|
||||
var errline = 0;
|
||||
function match_fn(s) {
|
||||
|
@ -2217,7 +2217,7 @@ function linkLWLINK(step:BuildStep) {
|
|||
if (toks[0] == 'Symbol:') {
|
||||
let ident = toks[1];
|
||||
let ofs = parseInt(toks[4], 16);
|
||||
if (ident && ofs >= 0 && !ident.startsWith("l_")) {
|
||||
if (ident && ofs >= 0 && !ident.startsWith("l_") && !/^L\d+$/.test(ident)) {
|
||||
symbolmap[ident] = ofs;
|
||||
}
|
||||
}
|
||||
|
@ -2235,7 +2235,8 @@ function linkLWLINK(step:BuildStep) {
|
|||
// TODO
|
||||
var lstout = FS.readFile(fn, {encoding:'utf8'});
|
||||
var asmlines = parseListing(lstout, /^([0-9A-F]+)\s+([0-9A-F]+)\s+[(]\s*(.+?)[)]:(\d+) (.*)/i, 4, 1, 2, 3);
|
||||
var srclines = [];
|
||||
// * Line //threed.c:117: init of variable e
|
||||
var srclines = parseSourceLines(lstout, /Line .+?:(\d+)/i, /^([0-9A-F]{4})/i);
|
||||
putWorkFile(fn, lstout);
|
||||
// TODO: you have to get rid of all source lines to get asm listing
|
||||
listings[fn] = {
|
||||
|
|
Loading…
Reference in New Issue