nedoPC.org

Electronics hobbyists community established in 2002
Atom Feed | View unanswered posts | View active topics It is currently 19 Apr 2024 14:24



Reply to topic  [ 146 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next
Плата центрального недопроцессора nedoCPU-32 
Author Message
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Начал городить опенсорцную либу:

https://github.com/shaos/xorlib

У автора осциллографа также разрешения спросил заюзать его код...


Attachments:
File comment: Одобрямс от оригинального автора
hackaday.gif
hackaday.gif [ 19.88 KiB | Viewed 10724 times ]

_________________
:dj: https://mastodon.social/@Shaos
31 Mar 2015 19:13
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
А вот на большом ТВ подсветка не выглядит столь привлекательной :(

Видимо придётся диод втыкать, чтобы было как на ZX - чёрный не должен подсвечиваться...


Attachments:
File comment: wrong highlight
Photo0149.jpg
Photo0149.jpg [ 61.47 KiB | Viewed 10865 times ]

_________________
:dj: https://mastodon.social/@Shaos
31 Mar 2015 21:04
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Shaos wrote:
Можно примерно подсчитать стоимость минимального игрового компьютера на PIC32, если бы пользователь собирал его сам на бредборде (по ценам DigiKey):

IC1: PIC32MX170F256B-I/SP - $4.49
LED1: красный светодиод 5 мм - $0.15
C1,C2: ненужны, если питаемся от батареек
C3,C4,C6: 0.1uF (ceramic) - 3*$0.24 = $0.72
C5: 10uF (ceramic) - $0.49
C7: ненужен, если питаемся от батареек
C8,C9: ненужны
R1: 10 Ohm - $0.10
R2: 10 kOhm - $0.10
R3,R4: 470 Ohm - 2*$0.10 = $0.20
X5: хедер для PICkit3 - примерно $0.20
S1-S7: кнопка ресета и игровые кнопки - 7*$0.12 = $0.72
Резисторы для кнопок - 6*$0.10 = $0.60
RCA разъёмы (звук и видео) - 2*$1 = $2 (примерно)
Резисторы для звука и видео - 5*$0.10 = $0.50
Держатель для двух пальчиковых батареек - $1 (плюс-минус)
Две пальчиковые батарейки - 2*$1 = $2 (примерно)

Всего $13.27 плюс бредборда и проводочки (ну скажем ещё $5) - по моему очень неплохо...


Короче задачу вижу так - разрабатываю простейшую схему на основе PIC32 (по сути уже готова), которую кто угодно с некривыми руками может собрать на бредборде, далее делаю опенсорцную либу на сях, пишу пару-тройку игр (в том числе 3D) - опять же на сях, а остальное сделает заинтересовавшийся народ - как идея? ;)

_________________
:dj: https://mastodon.social/@Shaos


01 Apr 2015 06:14
Profile WWW
Banned
User avatar

Joined: 04 Jan 2013 10:09
Posts: 397
Location: 95.24.178.158
Reply with quote
Shaos wrote:
...а остальное сделает заинтересовавшийся народ - как идея? ;)

Звучит уже как глас вопиющего в пустыне... :wink:

Может быть, сначала спросить:"Народ, а у вас есть эти самые PIC32 на 64 MHz?"


P.S. Я, кстати, что-то кварца в списочке компонентов не заметил...


01 Apr 2015 08:46
Profile
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Незнаю как у вас, а у нас они легко доставаемы (и разгоняемы до 80 МГц)...

P.S. Генератор там встроенный на 8 МГц из которого получаются внутренние частоты периферии и ядра (в нашем случае 32 МГц и 64 МГц).

_________________
:dj: https://mastodon.social/@Shaos


01 Apr 2015 09:02
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Попробую ка я программно генерить "NTSC color burst" - если у японца получилось, то и у меня получится :)

P.S. Первое, что надо сделать, это заюзать внешний кварц 14.31818 МГц вместо внутреннего осциллятора, чтобы задать точную частоту этого самого "NTSC color burst", которая должна быть ровно 3.579545 MHz...

P.P.S. Пока попробовал обмануть телевизор SONY путём тонкой подстройки частоты встроенного генератора клока и подбором резисторов глядя в осциллограф (получилось что-то похожее на вот это) - хотелось повторить CGA-трюк, но вышло нечто разноцветное - выводилась чёрно-белая картинка 768x200, захватывающая в том числе и "color burst" левым краем - видимо таки нужен точный кварц :)


Attachments:
File comment: composite trick
cgatrick_xbm2.gif
cgatrick_xbm2.gif [ 4.95 KiB | Viewed 10845 times ]
File comment: progammatical colors
Photo0150.jpg
Photo0150.jpg [ 146.59 KiB | Viewed 10845 times ]

_________________
:dj: https://mastodon.social/@Shaos
01 Apr 2015 15:42
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Shaos wrote:
А вот на большом ТВ подсветка не выглядит столь привлекательной :(

Видимо придётся диод втыкать, чтобы было как на ZX - чёрный не должен подсвечиваться...


От подсветки кусочков строк думаю придётся отказаться - этот Compare Output нужен будет для смещения "NTSC color burst" вниз (можно ещё им же внешнюю схемку задержки включать, чтобы немного сдвинуть фазу color-burst-a относительно всего остального для получения более аутентичных цветов)...

P.S. А пока вроде красивее, чем у японца получается - у него 5 ног на формирование видео уходит и основная зубодробилка написана на асме - у меня всего 3 ноги и всё на сях, кроме того по максимум задействована связка DMA+SPI для разгрузки проца!

P.P.S. Вот ещё про CGA-трюки статья: http://nerdlypleasures.blogspot.com/201 ... phics.html

P.P.P.S. Есть проблема (см. http://hackaday.io/post/2279 глава 9) - DMA в PIC32 произвольно выбирает моменты, когда надо выплёвывать слова, соответственно те цветовые изменения, что видны на вышеприведённой картинке, связаны не с нестабильностью генератора, а с тем, что DMA сам сдвигает фазу на 120 градусов каждые 32 пиксела!!! :evil:

_________________
:dj: https://mastodon.social/@Shaos


02 Apr 2015 07:41
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
На самом деле таки проблема была в неточности внутреннего генератора - как только подключил правильный внешний кварц (14.31818 МГц) и пересчитал все задержки под него (частота проца уменьшилась до 57.27272 МГц), то всё заработало :)


Attachments:
File comment: Black and white trick to get colors on composite
cgatrick_xbm0.gif
cgatrick_xbm0.gif [ 1.83 KiB | Viewed 10831 times ]
File comment: PIC32 color mode
Photo0151.jpg
Photo0151.jpg [ 172.58 KiB | Viewed 10831 times ]

_________________
:dj: https://mastodon.social/@Shaos
02 Apr 2015 18:45
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Хоть цвета справа немного и размазались, но в целом получилось - даже удалось какую-то степень схожести с CGA-трюками получить ;)

Наверное уже можно прямо так и оставить - не двигая никуда фазу color-burst-a...

P.S. Суть трюка в том, что ради экрана 640x200 пришлось ещё слева в каждую строку добавить 96 пикселов color-burst-a (9*4=36 пикселов) и пустоты перед видео (ещё 60) - т.е. всего получается в памяти картинка 736x200, которая занимает 18 килобайт! Это между прочим 28% всего ОЗУ самого большого PIC32 в DIP-e! Цветовое разрешение по горизонтали в 4 раза меньше чёрно-белого, т.е. вместо 640 получаем 160 (т.к. каждый цвет требует 4 чёрно-белых пиксела для самогенерации), да и чёрно-белое разрешение желательно сделать 320, чтобы цвета по ошибке не подхватывались...

P.P.S. Вот такая палитра получилась (усреднял по фотке), которую с какой-то погрешностью можно переложить на EGA-цвета:
Code:
#000000 - 0000 - black (no color)                   -> EGA 0 (black)
#205CA0 - 0001 - gray-blue                          ~> EGA 1 (blue)
#7030C0 - 0010 - dark purple                        ~> EGA 5 (magenta)
#6870E4 - 0011 - sky blue                           -> EGA 9 (bright blue)
#883020 - 0100 - dark brown                         ~> EGA 4 (red)
#545054 - 0101 - gray (no color)                    ~> EGA 7 (white)
#CC5494 - 0110 - pink                               ~> EGA 12 (bright red)
#A440EC - 0111 - light purple                       ~> EGA 13 (bright magenta)
#0C5420 - 1000 - dark green                         -> EGA 2 (green)
#2CA884 - 1001 - light gray-green                   ~> EGA 3 (cyan)
#585460 - 1010 - gray (no color)                    -> EGA 8 (gray)
#147CE8 - 1011 - light blue                         -> EGA 11 (bright cyan)
#989838 - 1100 - yellow (identical to color burst)  -> EGA 14 (yellow)
#24BC38 - 1101 - light green                        -> EGA 10 (bright green)
#C86030 - 1110 - light brown                        -> EGA 6 (brown)
#A098B0 - 1111 - white (no color)                   -> EGA 15 (bright white)

Цветов на самом деле 15, т.к. серый 0101 идентичен серому 1010 (в CGA они были разные возможно из-за разной ширины чётных и нечётных пикселов)...


Attachments:
File comment: PIC32 colors
PIC32-colors.gif
PIC32-colors.gif [ 6.65 KiB | Viewed 10830 times ]

_________________
:dj: https://mastodon.social/@Shaos
02 Apr 2015 18:56
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Видимо от режима 256x200 с почти что квадратными пикселами (и круглыми окружностями) придётся отказаться (ну не натягивается он на частоту 57.27272 МГц) - в результате остаются только ПЦ режимы - 320x200 да 640x200 с цветом и без...

P.S. Вот окончательная отцентрированная версия тестовых цветов для 640x200 (на широкоэкранном ТВ растянуто и близко к 16:9):
 исходник тут
Code:
/*******************************************************************
 *
 * Based on "NTSC TV interface" examples from
 * http://hackaday.io/project/2032-pic32-oscilloscope
 * Bruce Land Cornell University
 * June 2014
 * This code uses many cool ideas from
 * Programming 32-bit Microcontrollers in C: Exploring the PIC32
 * by Lucio Di Jasio
 *
 * Uses two Compare units from one timer to do sync and video timing
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 * VIDEO is PortA.1
 * SYNC  is PortB.1
 *
 */

#include <plib.h>
#include <xc.h> // need for pps
#include <stdio.h>
#include <stdlib.h>
//#include <math.h>

//                       8MHZ                          4MHz               60MHz            30   <-----<---    60MHz
//#pragma config FNOSC = FRCPLL, POSCMOD = OFF, FPLLIDIV = DIV_2, FPLLMUL = MUL_15, FPBDIV = DIV_2, FPLLODIV = DIV_1

//                     14.31818MHZ                      3.579545MHz      57.27272MHz      28.63636  <-----<--- 57.27272MHz
#pragma config FNOSC = PRIPLL, POSCMOD = HS, FPLLIDIV = DIV_4, FPLLMUL = MUL_16, FPBDIV = DIV_2, FPLLODIV = DIV_1
#pragma config FWDTEN = OFF
#pragma config FSOSCEN = OFF, JTAGEN = OFF
// core frequency we're running at // peripherals at 40 MHz
#define  SYS_FREQ 57272720

#define PITCH 23
#define OFFSET 96
#define TOFFSET (OFFSET/8)
#define DX (OFFSET+640)
#define DY (200)
#define SCREENSZ (DX*DY/32)
int screen_buffer[SCREENSZ] ;
volatile int *screen_buffer_addr = screen_buffer ;
volatile int *screen_ptr ;

// The DMA channels
#define DMAchn1 1
#define DMApri0 0

// video timing
#define line_cycles 1818 // 63.5 uSec at 28.6 MHz Fpb, prescaler=1
#define line_offset  159 // offset to start video screen
#define us_5_cycles  135 // 5 uSec at 28.6 MHz Fpb, prescaler=1

// video active lines -- 200 total
#define image_start 20
#define image_end (image_start+DY)
#define top 0
#define left 0
#define right 639
#define bottom 199

// Current line number which is modified
// by a state machine in the timer2 ISR
volatile int LineCount = 0 ;
// ISR driven 1/60 second time
volatile int time_tick_60_hz = 0 ;
// ISR driven seconds counter
volatile int time_seconds = 0;
// Absolute frame counter
volatile unsigned long time_frames = 0;

#include "nedofont.h"

#include "cgatrick.xbm"

#define WAIT 180

// == OC3 ISR ============================================
// VECTOR 14 is OC3 vector -- set up of ipl3 in main
// vector names from int_1xx_2xx.h
void __ISR(14, ipl3) OC3Handler(void) // 14
{
    if(time_frames>WAIT){
    // mPORTBSetBits(BIT_1);
    // Convert DMA to SPI control
    DmaChnSetEventControl(DMAchn1, DMA_EV_START_IRQ(_SPI1_TX_IRQ)); //
    //DmaChnEnable(DMAchn1);
    // clear the timer interrupt flag -- name from
    // http://people.ece.cornell.edu/land/courses/ece4760/PIC32/Microchip_stuff/32-bit-Peripheral-Library-Guide.pdf
    // Table 8.2
    mOC3ClearIntFlag();
   // mPORTBClearBits(BIT_1);  // for profiling the ISR execution time
    }
}

volatile short sound[]={
750,785,821,856,891,926,961,995,1028,1061,1093,1124,1155,1185,1213,1241,
1267,1292,1316,1339,1360,1380,1399,1416,1432,1446,1458,1469,1478,1486,1492,1496,
1499,1499,1499,1496,1492,1486,1478,1469,1458,1446,1432,1416,1399,1380,1360,1339,
1316,1292,1267,1241,1213,1185,1155,1125,1093,1061,1028,995,961,926,891,856,
821,785,750,714,678,643,608,573,538,504,471,438,406,375,344,314,
286,258,232,207,183,160,139,119,100,83,67,53,41,30,21,13,
7,3,0,0,0,3,7,13,21,30,41,53,67,83,100,119,
139,160,183,207,232,258,286,314,344,374,406,438,471,504,538,573,
608,643,678,714,749,785,821,856,891,926,961,995,1028,1061,1093,1124,
1155,1185,1213,1241,1267,1292,1316,1339,1360,1380,1399,1416,1432,1446,1458,1469,
1478,1486,1492,1496,1499,1499,1499,1496,1492,1486,1478,1469,1458,1446,1432,1416,
1399,1380,1360,1339,1316,1292,1267,1241,1213,1185,1155,1125,1093,1061,1028,995,
961,926,891,856,821,785,750,714,678,643,608,573,538,504,471,438,
406,375,344,314,286,258,232,207,183,160,139,119,100,83,67,53,
41,30,21,13,7,3,0,0,0,3,7,13,21,30,41,53,
67,83,100,119,139,160,183,207,232,258,286,314,344,374,406,438,
471,504,538,573,608,643,678,714
};


// == Timer 2 ISR =========================================
void __ISR(_TIMER_2_VECTOR, ipl2) Timer2Handler(void)
{
    //mPORTBSetBits(BIT_1); // for profiling the ISR execution time
    // update the current scanline number
    LineCount++ ;
/*
//    OpenOC5(OC_ON | OC_TIMER2_SRC | OC_CONTINUE_PULSE, line_offset+18+sound[LineCount], line_offset+12);
    if(LineCount >= image_start + 20 && LineCount < image_end - 100)
      OpenOC5(OC_ON | OC_TIMER2_SRC | OC_SINGLE_PULSE, line_offset+300, line_offset+200);
    else
      CloseOC5(); 
*/       
    // start the DMA byte blaster to the screen
    if (LineCount >= image_start && LineCount < image_end){
        if(time_frames>WAIT){
        // set the Chan1 DMA transfer parameters: source & destination address,
        // source & destination size, number of bytes per event
        // 32 bytes / line with 4 bytes per transfer (SPI in 32 bit mode)
        //screen_ptr = screen_buffer + ((LineCount - image_start)<<5) ;
        DmaChnSetTxfer(DMAchn1, (void*)screen_ptr, (void*)&SPI1BUF, 92, 4, 4);
        // IRO 17 is the output compare 3 interrupt (See datasheet table 7.1)
        DmaChnSetEventControl(DMAchn1, DMA_EV_START_IRQ(17)); //
        // turn it on for 32 bytes
        DmaChnEnable(DMAchn1);
        }
        // increment the image memory pointer for the next ISR pass
        screen_ptr += PITCH; // PITCH 32-bit words per line
    }
    // update the frame time_tick immediately after image is copied
    else if(LineCount==image_end)
    {
        // a general propose time base
        if((++time_tick_60_hz%60)==0) time_seconds++;       
    }
    // == SYNC state machine ====
    // begin long (Vertical) synch after line 247
    else if (LineCount==248) {OC2R = line_cycles - us_5_cycles ;}
    // back to regular sync after line 250
    // the first condition eliminates sync for one line (to avoid duplicate)
    else if (LineCount==250) {OC2R = 0 ;}
    else if (LineCount==251) {OC2R = us_5_cycles ;}
    // start new frame after line 262 and reset the image memory pointer
    else if (LineCount==263) {
        LineCount = 1;
        // reset for the next frame
        screen_ptr = screen_buffer_addr;
       
        time_frames++;
    }
   
    // clear the timer interrupt flag
    mT2ClearIntFlag();
    //mPORTBClearBits(BIT_1);  // for profiling the ISR execution time
}

//== plot a point =========================================================
//plot one point
//at x,y with color 1=white 0=black 2=invert
void video_pt(int x, int y, char c) {
   //calculate i based upon this and x,y
   // the word with the pixel in it
   //int i = (x/32) + y*PITCH
   x += OFFSET;
   if (c==1)
     screen_buffer[(x >> 5) + (y * PITCH)] |= 1<<(31-(x & 0x1f));
    else if (c==0)
     screen_buffer[(x >> 5) + (y * PITCH)] &= ~(1<<(31-(x & 0x1f)));
    else // c==2
     screen_buffer[(x >> 5) + (y * PITCH)] ^= 1<<(31-(x & 0x1f));
}

//==================================
//plot a line
//at x1,y1 to x2,y2 with color 1=white 0=black 2=invert
//NOTE: this function requires signed chars
//Code is from David Rodgers,
//"Procedural Elements of Computer Graphics",1985
void video_line(int x1, int y1, int x2, int y2, char c) {
   int e;
   signed int dx,dy,j, temp;
   signed char s1,s2, xchange;
        signed int x,y;

   x = x1;
   y = y1;

   //take absolute value
   if (x2 < x1) {
      dx = x1 - x2;
      s1 = -1;
   }

   else if (x2 == x1) {
      dx = 0;
      s1 = 0;
   }

   else {
      dx = x2 - x1;
      s1 = 1;
   }

   if (y2 < y1) {
      dy = y1 - y2;
      s2 = -1;
   }

   else if (y2 == y1) {
      dy = 0;
      s2 = 0;
   }

   else {
      dy = y2 - y1;
      s2 = 1;
   }

   xchange = 0;

   if (dy>dx) {
      temp = dx;
      dx = dy;
      dy = temp;
      xchange = 1;
   }

   e = ((int)dy<<1) - dx;

   for (j=0; j<=dx; j++) {
      video_pt(x,y,c);

      if (e>=0) {
         if (xchange==1) x = x + s1;
         else y = y + s2;
         e = e - ((int)dx<<1);
      }

      if (xchange==1) y = y + s2;
      else x = x + s1;

      e = e + ((int)dy<<1);
   }
}

//==================================
//return the value of one point
//at x,y with color 1=white 0=black
char video_state(int x, int y) {
    //The following construction detects exactly one bit at the x,y location
    return (screen_buffer[((x+OFFSET) >> 5) + (y * PITCH)] & (1<<(31-(x & 0x1f))))?1:0 ;
}

//==================================
// put a big character on the screen
// c is index into bitmap
void video_putchar(int x, int y, int c) {
    x += TOFFSET;
    int j = (x>>2)+(y<<3)*PITCH;
    int shf = (3-(x&3))<<3;
    int msk = ~(255<<shf);
    unsigned char *ptr = font8x8[c-32];
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*(ptr++)<<shf);j+=PITCH;
    screen_buffer[j]=(screen_buffer[j] & msk)|(*ptr<<shf);
}

//==================================
// put a string of big characters on the screen
void video_string(int x, int y, char *str) {
   char i;
   for (i=0; str[i]!=0; i++) {
      video_putchar(x++,y,str[i]);
   }
}

// ========================================================================
int   main(void)
{
    int* iptr;
    float f;
    unsigned long i,j,n,m,stored,maxstored=0;
    // global time
    int time, seconds, x, y, k, c;
    char time_string[10] ;
    int osctun = 0x3F;

   // Configure the device for maximum performance but do not change the PBDIV
   // Given the options, this function will change the flash wait states, RAM
   // wait state and enable prefetch cache but will not change the PBDIV.
   // The PBDIV value is already set via the pragma FPBDIV option above..
   SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

   
    //make sure analog is cleared
    //ANSELA =0;
    //ANSELB =0;

    // timer interrupt //////////////////////////
    // Set up timer2 on,  interrupts, internal clock, prescalar 1, toggle rate
    // 63.5 microSec
    OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_1, line_cycles);
    // set up the timer interrupt with a priority of 2
    ConfigIntTimer2(T2_INT_ON | T2_INT_PRIOR_2);
    mT2ClearIntFlag(); // and clear the interrupt flag

    // Compare match setup //////////////////////
    //Set up compare match unit to produce sync pulses
    // 5 uSec low
    // or 63.5-5 = 58.5 microSec (2340 ticks) low
    // pulse duration will be controlled in Timer2 ISR
    // #define OpenOC2( config, value1, value2) ( OC2RS = (value1), OC2R = (value2), OC2CON = (config) )
    OpenOC2(OC_ON | OC_TIMER2_SRC | OC_CONTINUE_PULSE, line_cycles-1, us_5_cycles);
    // OC2 is PPS group 2, map to RPB1 (pin 5)
    PPSOutput(2, RPB1, OC2);

    // OC3 setup /////////////////////////////////
    // Compare unit for video timing,
    // using the interrupt flag to trigger the first DMA,
    // then use the ISR to change the DMA control to SPI
    // #define OpenOC2( config, value1, value2) ( OC2RS = (value1), OC2R = (value2), OC2CON = (config) )
    // Pulse needs to be TWO cycles long
    OpenOC3(OC_ON | OC_TIMER2_SRC | OC_CONTINUE_PULSE, line_offset+2, line_offset);
    // turn on ISR so that DMA can covert to SPI control
    ConfigIntOC3(OC_INT_PRIOR_1 | OC_INT_ON); //3 //
    mOC3ClearIntFlag(); // and clear the interrupt flag

    // OC4 setup /////////////////////////////////
    OpenOC4(OC_ON | OC_TIMER2_SRC | OC_CONTINUE_PULSE, line_offset+40, line_offset+112);
    // OC4 is PPS group 3, map to RPB13 (pin 24)
    PPSOutput(3, RPB13, OC4);

    // OC5 setup /////////////////////////////////
    OpenOC5(OC_ON | OC_TIMER2_SRC | OC_CONTINUE_PULSE, line_cycles-200, line_cycles-100);
    // OC5 is PPS group 3, map to RPA2 (pin 9)
    PPSOutput(3, RPA2, OC5);
   
    // SPI configure /////////////////////////////
    // SCK1 is pin 25 RB14
    // SDO1 is PPS group 2, map to RPA1 (pin 3)
    // SDI1 is PPS group 2, map to RPB8 (pin 17) ???
    // SS1 input is PPS group 1, map to RPB7 (pin 16) for framing
    // specify PPS group, signal, logical pin name
    PPSInput (1, SS1, RPB7);
    PPSOutput(2, RPA1, SDO1);
    // control sync for DAC
    mPORTBSetPinsDigitalOut(BIT_0|BIT_2|BIT_3);
    mPORTBSetBits(BIT_0);
    mPORTBClearBits(BIT_2);
    mPORTBClearBits(BIT_3);

    // divide Fpb by N, configure the I/O ports. 32 bit transfer
    SpiChnOpen(SPI_CHANNEL1, SPI_OPEN_ON | SPI_OPEN_MODE32 | SPI_OPEN_MSTEN , 2); // N=6

    //=== DMA Channel 1 ================================
    // Open DMA Chan1 and chain from channel zero
    DmaChnOpen(DMAchn1, DMApri0, DMA_OPEN_DEFAULT);

    // setup system wide interrupts  ///
    INTEnableSystemMultiVectoredInt();

    iptr = (int*)cgatrick_bits;
    for(i=0;i<SCREENSZ;i++)
    {
        k = iptr[i];
        c = 0;
        n = 1;
        m = 0x80000000;
        for(j=0;j<32;j++)
        {
          if(!(k&n)) c|=m;
          n <<= 1;
          m >>= 1;
        }
        screen_buffer[i] = c;
    }

    // Draw the screen boundaries
    video_line(left,top, right,top, 1); // top
    video_line(right,top, right,bottom, 1); // right
    video_line(right,bottom, left,bottom, 1); // bottom
    video_line(left,top, left,bottom ,1); // left

    // Draw a title
    video_string(0,0,"nedoPC-32-A v1.0 (April 2, 2015)");

    seconds = stored = n = x = y = 0;
    c = 32;
    k = 0;
    srand(11111);
    while(1)
    {       
            n++;
#if 0
            // random characters
            k = rand();
            video_putchar(k%80,2+((k>>6)&15),++c);
            if(c==255) c=31;
#endif
#if 0
            // random lines
            k = rand();
            c = k&511; k=8+((k>>8)%184);
            video_line(x,y,c,k,2);
            x = c; y = k;
#endif
#if 0
            // random pixels
            k = rand();
            video_pt(k%640,8+((k>>9)%184),2);
#endif
            if(time != time_tick_60_hz)
            {
                time = time_tick_60_hz ;
                stored = n;
                if(n>maxstored) maxstored=n;
                n = 0;               
           
              if(seconds != time_seconds)
              {
                seconds = time_seconds;
                sprintf(time_string, "%d:%4.4X %d (max=%d)",seconds,PORTB,stored,maxstored);
                video_string(0, 24, time_string);
/*
                if(mPORTBReadBits(BIT_8)||mPORTBReadBits(BIT_9))
                {
                    if(mPORTBReadBits(BIT_8)) osctun--;
                    if(mPORTBReadBits(BIT_9)) osctun++;

                    unsigned int status1, status2;
mSYSTEMUnlock(status1, status2);
//change some system settings
OSCTUN = osctun;
mSYSTEMLock(status1, status2);

                 }
*/               
                if(seconds&1)
                    mPORTBClearBits(BIT_2);
                else
                    mPORTBSetBits(BIT_2);

                if(seconds&2)
                    mPORTBClearBits(BIT_3);
                else
                    mPORTBSetBits(BIT_3);
              }
            }
    }

}


Attachments:
File comment: Test chart with color-burst
cgatrick_xbm000.gif
cgatrick_xbm000.gif [ 3.41 KiB | Viewed 10825 times ]
File comment: Color TV widescreen
Photo0152.jpg
Photo0152.jpg [ 118.05 KiB | Viewed 10825 times ]
File comment: Grayscale TV
Photo0153.jpg
Photo0153.jpg [ 67.85 KiB | Viewed 10825 times ]

_________________
:dj: https://mastodon.social/@Shaos
02 Apr 2015 23:33
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Shaos wrote:
Видимо от режима 256x200 с почти что квадратными пикселами (и круглыми окружностями) придётся отказаться (ну не натягивается он на частоту 57.27272 МГц) - в результате остаются только ПЦ режимы - 320x200 да 640x200 с цветом и без...


С другой стороны 256x200 тоже можно оставить как вариант - ведь с ним всё быстрее и без кварца можно обойтись...

_________________
:dj: https://mastodon.social/@Shaos


04 Apr 2015 02:52
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Вот, например, что можно сделать с этими 15 цветами в 160x200 - растянуто до 640x480 для сохранения пропорций ;)

P.S. Размер этого GIF-файла 160x200 составляет 9281 байт, а несжатая картинка 160x200 с 16 цветами весит 16000 байт...


Attachments:
File comment: DOOM 160x200 rescaled to 320x240
Doom-160x200-scaled.gif
Doom-160x200-scaled.gif [ 14.1 KiB | Viewed 10789 times ]

_________________
:dj: https://mastodon.social/@Shaos
04 Apr 2015 19:43
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Shaos wrote:
Начал городить опенсорцную либу:

https://github.com/shaos/xorlib

У автора осциллографа также разрешения спросил заюзать его код...


Про либу теперь в другом месте:

http://www.nedopc.org/forum/viewtopic.php?f=81&t=10948

_________________
:dj: https://mastodon.social/@Shaos


04 Apr 2015 19:51
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
А ещё можно портануть AGI-интерпретатор и крутить некоторое количество старых квестов от сьерры ;)

http://sarien.sourceforge.net/screenshots/page1.php

Там и цвета подходящие, и разрешение :)

_________________
:dj: https://mastodon.social/@Shaos


05 Apr 2015 09:04
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22543
Location: Silicon Valley
Reply with quote
Ой, а цветов то там сильно больше! :o

Оказалось, что в чётных и нечётных строках один и тот же паттерн генерит разные цвета!!!

Например паттерн жёлтого (четвёртый цвет снизу) разбивается на красный и зелёный и процессор моего ТВ склеивает их вместе так, что оно видится как жёлтый (если оставлять соседнюю строчку чёрной - то будет видны красный или зелёный в зависимости от того в чётной мы строке или нечётной):


Attachments:
File comment: More NTSC colors
Photo0159.jpg
Photo0159.jpg [ 87.66 KiB | Viewed 10778 times ]

_________________
:dj: https://mastodon.social/@Shaos
06 Apr 2015 08:12
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 146 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next

Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.