Post by Malban on Dec 25, 2018 14:25:34 GMT -5
Following code works (in Vide):
#include <vectrex.h>
static void cstrcpy(char *dest, char *src) {
char c; do { c = *src++; *dest++ = c; } while (c != '\0');
}
static char DEMO[15];
static void cMoveto_d(signed int y, signed int x)
{
dp_VIA_port_a = y; // y pos to dac
dp_VIA_cntl = 0xce; // disable zero, disable all blank
dp_VIA_port_b = 0; // mux enable, dac to -> integrator y (and x)
dp_VIA_shift_reg = 0; // all output is BLANK
dp_VIA_port_b++; // mux disable, dac only to x
dp_VIA_port_a = x; // dac -> x
dp_VIA_t1_cnt_hi=0; // start timer
while ((dp_VIA_int_flags & 0x40) == 0); // wait till timer finishes
}
__attribute__((interrupt)) static void draw_graphics(void)
{
if ((dp_VIA_int_flags & 0x20) == 0) {
// for anything except the t2 timer we want to rti immediately.
return;
}
Vec_Loop_Count++;
dp_VIA_t2 = Vec_Rfrsh;
dp_VIA_t1_cnt_lo= (unsigned int)255;
cMoveto_d(127,127);
dp_VIA_cntl = 0xcc; // enable zero, enable all blank
cMoveto_d(-128,-128);
dp_VIA_cntl = 0xcc; // enable zero, enable all blank
dp_VIA_port_a = 0; // dac = 0
dp_VIA_port_b = 3; // mux=1, disable mux
dp_VIA_port_b = 2; // mux=1, enable mux
dp_VIA_port_b = 2; // delay
dp_VIA_port_b = 1; // disable mux
// graphics executed here. Small placeholder for now:
Print_Str_d(0, -70, DEMO);
<span style="font-family: Verdana, Arial; font-size: 10pt;">}</span>
#define IRQBASE 0xCBF8 // this must be IRQ not FIRQ!
unsigned long volatile * const IRQ = (unsigned long *) (IRQBASE+1);
unsigned int volatile * const IRQ_INST = (unsigned int *) IRQBASE;
int main(void)
{
char *p;
*IRQ_INST = (unsigned int)0x7e; // JMP ... this is actually code!, first a JMP instruction
*IRQ = (unsigned long)&draw_graphics; // to Address
cstrcpy(DEMO, "HELLO 0000000\x80"); // long enough to allow freewheeling counter...
p = DEMO+12;
// ENABLE INTERRUPTS HERE! (How???)
// ensure timer is sensible to start with
dp_VIA_t2 = Vec_Rfrsh;
dp_VIA_int_enable |= 0x20;
asm("andcc #0xef"); // enable IRQ with 6809
for (;;) {
while (*p == '9') { // find digit to increment - X9999 becomes (X+1)0000
*p = '0';
p -= 1;
if (*p == ' ') {
cstrcpy(DEMO, "HELLO 0000000\x80");
p = DEMO+12;
}
}
*p += 1;
p = DEMO+12;
// Print_Str_d(0, -70, DEMO);
// Only display once every 1/50s in interrupt routine
}
return 1; // cold reset - NOT REACHED
}