Changeset 90b6d4b in thomson


Ignore:
Timestamp:
Mar 17, 2013, 8:46:21 AM (11 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
1180ce9
Parents:
2495b14
Message:

Work on MEATrakcer continues with some input and cursor handling.

git-svn-id: svn://localhost/thomson@44 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

Location:
code/C/meatracker
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/C/meatracker/Makefile

    r2495b14 r90b6d4b  
    33        cp obj/tracker.K5 ../../../../mo5/dcmo5/software/tracker.K7
    44
    5 obj/tracker.bin:: obj/main.o obj/display.o obj/text.o obj/font_hs2.o
     5obj/tracker.bin:: obj/main.o obj/display.o obj/text.o obj/font_hs2.o obj/input.o
    66
    77###############################################################################
    88CC=m6809-thomson-none-gcc
    9 CFLAGS=-O3 -save-temps=obj -Wall
     9CFLAGS=-O3 -save-temps=obj -Wall -std=gnu99
    1010
    1111obj/%.K5: obj/%.bin
  • code/C/meatracker/display.c

    r2495b14 r90b6d4b  
     1#include "display.h"
     2
    13#include <text.h>
     4
     5char music[8][16];
    26
    37static const char* notes = "C C#D D#E F F#G G#A A#B --";
    48
    5 static const char FM1[] = {
     9const char FM1[] = {
    6102,'3',  4,'3', 5,'3',  6,'3', 7,'3',  9,'3', 10,'3', 11,'3',
    7110,'4',  2,'4', 3,'4',  4,'4', 5,'4',  6,'4',  7,'4',  8,'4',
     
    1115};
    1216
    13 static const char FM2[] = {
     17const char FM2[] = {
    14189,'4', 10,'4', 11,'4', 0,'5', 1,'5',  2,'5',  3,'5',  4,'5',
    15195,'5',  6,'5',  7,'5', 8,'5', 9,'5', 10,'5', 11,'5',  0,'6',
     
    1923};
    2024
    21 static const char FM3[] = {
     25const char FM3[] = {
    22262,'6', 4,'6', 7,'6', 9,'6', 0,'7', 2,'7', 5,'7', 8,'7'
    2327};
     
    2529static const char FM4[] = { 9,'7' };
    2630
    27 void printnote(char channel, char pos, char note)
     31void printnote(unsigned char channel, unsigned char pos)
    2832{
    29         if (channel > 3) return;
     33        if (channel > 6) return;
    3034
    31         char n, o;
    32         pos *= 8;
     35        uint8_t note = music[channel][pos];
     36        char fbw = '1' + music[channel+1][pos];
     37
     38        uint8_t n = 12, o = '?';
    3339        if (note >= 0)
    3440        {
     
    3945                        n = FM1[note]; o = FM1[note+1];
    4046                        break;
    41                 case 1:
     47                case 2:
    4248                        n = FM2[note]; o = FM2[note+1];
    4349                        break;
    44                 case 2:
     50                case 4:
    4551                        n = FM3[note]; o = FM3[note+1];
    4652                        break;
    47                 case 3:
     53                case 6:
    4854                        n = FM4[note]; o = FM4[note+1];
    4955                        break;
    5056        }
    51         } else {
    52                 n = 12;
    5357        }
    5458
    55         channel *= 5;
     59
     60        pos *= 8;
     61
     62        if(channel == 2) channel = 5;
     63        else if(channel == 4) channel = 10;
     64        else if(channel == 6) channel = 15;
     65
    5666        n *= 2;
     67
    5768        drawchar(notes[n],     channel++, pos);
    5869        drawchar(notes[n + 1], channel++, pos);
    59         drawchar(o,            channel,   pos);
     70        drawchar(o,            channel++, pos);
     71        drawchar(fbw,          channel,   pos);
    6072}
    6173
     
    6476        int x,y;
    6577
    66         for(x = 0; x < 4; x++)
     78        for(x = 0; x < 8; x+=2)
    6779        for(y = 0; y < 16; y++)
    6880        {
    69                 printnote(x, y, 0);
     81                printnote(x, y);
    7082        }
     83
     84        // TODO HEADER
     85        // FM1  FM2  FM3  FM4  GEN
     86        // nnnW nnnW nnnW nnnW sldCRVD
     87        // ---  ---  ---  ---  nnnCR                   
     88
     89        cursor(cursorx, cursory);
    7190}
     91
     92void cursor(uint8_t x, uint8_t y)
     93{
     94        uint8_t* destp = (uint8_t*)(x*2) + y * 8 * 40;
     95
     96        if(x>1) ++destp;
     97        if(x>3) ++destp;
     98        if(x>5) ++destp;
     99        if(x>7) ++destp;
     100
     101        int val = 0xFFFF;
     102        if(x == 1 || x == 3 || x == 5 || x == 7) val = 0xFF;
     103        uint16_t* dest = (uint16_t*)destp;
     104        *dest ^= val; dest +=20;
     105        *dest ^= val; dest +=20;
     106        *dest ^= val; dest +=20;
     107        *dest ^= val; dest +=20;
     108        *dest ^= val; dest +=20;
     109        *dest ^= val; dest +=20;
     110        *dest ^= val; dest +=20;
     111        *dest ^= val; dest +=20;
     112}
  • code/C/meatracker/display.h

    r2495b14 r90b6d4b  
     1#include "stdint.h"
     2
    13void refreshchannels();
     4void cursor(uint8_t x, uint8_t y);
     5
     6extern unsigned char cursorx, cursory;
  • code/C/meatracker/main.c

    r2495b14 r90b6d4b  
    66
    77#include "display.h"
     8#include "input.h"
     9
     10volatile unsigned char* MEA_DATA = (unsigned char*)0xA7CE;
     11extern unsigned char music[8][16];
     12
     13uint8_t isplaying = 1;
    814
    915int main(void)
    1016{
     17        asm(" ORCC #$50"); // Disable interrupts (cursor blink)
    1118        refreshchannels();
     19
     20
     21        for(int frame = 0;;frame++)
     22        {
     23                if((frame & 0x3) == 0)
     24                        input();
     25               
     26                if(isplaying)
     27                {
     28                        /*
     29                        *MEA_DATA = music[0][frame & 0xF];
     30                        *MEA_DATA = music[1][frame & 0xF];
     31                        *MEA_DATA = music[2][frame & 0xF];
     32                        *MEA_DATA = music[3][frame & 0xF];
     33                        */
     34
     35                        *(MEA_DATA + 1) = 0x12;
     36                        *MEA_DATA = 110;
     37
     38                        // BW
     39                        *MEA_DATA = (music[1][frame & 0xF] << 6) |
     40                                                (music[3][frame & 0xF] << 4) |
     41                                                (music[5][frame & 0xF] << 2) |
     42                                                (music[7][frame & 0xF]);
     43
     44                        // FREQ
     45                        *MEA_DATA = (music[2][frame & 0xF] << 5) |
     46                                                (music[4][frame & 0xF]);
     47
     48                        // FREQ / AMPL
     49                        *MEA_DATA = (music[0][frame & 0xF] << 3) | 0xF; // TODO AMPL
     50
     51                        // AMPL / DUR / PERIODCHANGE
     52                        *MEA_DATA = 0xD1; // TODO AMPL / DUR / PERIODCHANGE
     53                }
     54
     55                asm("\n"
     56"z      TST     0xA7E7  \n"
     57"       BMI z           \n"
     58"bb     TST     0xA7E7  \n"
     59"       BPL bb          \n"
     60                );
     61        }
     62
    1263        return 0;
    1364}
Note: See TracChangeset for help on using the changeset viewer.