Beispiel #1
0
 private void DisplayLigne(bool forceRender)
 {
     doRender            = false;
     curLigneSplit       = bitmapCpc.splitEcran.GetLigne((int)numLigne.Value);
     numPen.Value        = curLigneSplit.numPen;
     lblColor0.Visible   = largSplit0.Visible = chkSplit0.Checked = curLigneSplit.GetSplit(0).enable;
     largSplit0.Value    = curLigneSplit.GetSplit(0).longueur;
     lblColor0.BackColor = System.Drawing.Color.FromArgb(BitmapCpc.RgbCPC[curLigneSplit.GetSplit(0).couleur].GetColorArgb);
     lblColor1.Visible   = largSplit1.Visible = chkSplit1.Checked = curLigneSplit.GetSplit(1).enable;
     largSplit1.Value    = curLigneSplit.GetSplit(1).longueur;
     lblColor1.BackColor = System.Drawing.Color.FromArgb(BitmapCpc.RgbCPC[curLigneSplit.GetSplit(1).couleur].GetColorArgb);
     lblColor2.Visible   = largSplit2.Visible = chkSplit2.Checked = curLigneSplit.GetSplit(2).enable;
     largSplit2.Value    = curLigneSplit.GetSplit(2).longueur;
     lblColor2.BackColor = System.Drawing.Color.FromArgb(BitmapCpc.RgbCPC[curLigneSplit.GetSplit(2).couleur].GetColorArgb);
     lblColor3.Visible   = largSplit3.Visible = chkSplit3.Checked = curLigneSplit.GetSplit(3).enable;
     largSplit3.Value    = curLigneSplit.GetSplit(3).longueur;
     lblColor3.BackColor = System.Drawing.Color.FromArgb(BitmapCpc.RgbCPC[curLigneSplit.GetSplit(3).couleur].GetColorArgb);
     lblColor4.Visible   = largSplit4.Visible = chkSplit4.Checked = curLigneSplit.GetSplit(4).enable;
     largSplit4.Value    = curLigneSplit.GetSplit(4).longueur;
     lblColor4.BackColor = System.Drawing.Color.FromArgb(BitmapCpc.RgbCPC[curLigneSplit.GetSplit(4).couleur].GetColorArgb);
     lblColor5.Visible   = largSplit5.Visible = chkSplit5.Checked = curLigneSplit.GetSplit(5).enable;
     largSplit5.Value    = curLigneSplit.GetSplit(5).longueur;
     lblColor5.BackColor = System.Drawing.Color.FromArgb(BitmapCpc.RgbCPC[curLigneSplit.GetSplit(5).couleur].GetColorArgb);
     doRender            = true;
     if (chkAutoApplique.Checked || forceRender)
     {
         UpdatePalette();
         Render();
     }
 }
Beispiel #2
0
        public void CalcPaletteSplit()
        {
            int[] curPal = new int[16];
            for (int i = 0; i < 16; i++)
            {
                curPal[i] = Palette[0, 0, i];
            }

            // Raz splits
            for (int y = 0; y < 272; y++)
            {
                for (int x = 0; x < 96; x++)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        Palette[x, y, i] = curPal[i];
                    }
                }
            }

            int numCol = 0;

            for (int y = 0; y < 272; y++)
            {
                LigneSplit lSpl = splitEcran.LignesSplit[y];
                numCol = lSpl.numPen;
                int xpos = lSpl.retard >> 2;
                // de x à xpos => faire palette = curPal
                int x = AppliquePalette(0, y, xpos, curPal);
                for (int ns = 0; ns < 6; ns++)
                {
                    Split s = lSpl.GetSplit(ns);
                    if (s.enable)
                    {
                        xpos          += s.longueur >> 2;
                        curPal[numCol] = s.couleur;
                        if (xpos > 96)
                        {
                            xpos = 96;
                        }

                        // de x à xpos => faire palette = curPal
                        x = AppliquePalette(x, y, xpos, curPal);
                    }
                    else
                    {
                        break;
                    }
                }
                // Terminer ligne
                AppliquePalette(x, y, 96, curPal);
                if (y < 271 && lSpl.changeMode)
                {
                    tabMode[y + 1] = lSpl.newMode;
                }
            }
        }
Beispiel #3
0
 private void bpCopieLigne_Click(object sender, EventArgs e)
 {
     if ((int)numLigne.Value > 0)
     {
         LigneSplit lignePrec = bitmapCpc.splitEcran.GetLigne((int)numLigne.Value - 1);
         curLigneSplit.numPen     = lignePrec.numPen;
         curLigneSplit.retard     = lignePrec.retard;
         curLigneSplit.changeMode = lignePrec.changeMode;
         curLigneSplit.newMode    = lignePrec.newMode;
         for (int i = 0; i < 6; i++)
         {
             curLigneSplit.ListeSplit[i].enable   = lignePrec.ListeSplit[i].enable;
             curLigneSplit.ListeSplit[i].couleur  = lignePrec.ListeSplit[i].couleur;
             curLigneSplit.ListeSplit[i].longueur = lignePrec.ListeSplit[i].longueur;
         }
         DisplayLigne(false);
     }
 }
Beispiel #4
0
        public void Render()
        {
            if (doRender)
            {
                bitmapCpc.CalcPaletteSplit();
                bitmapCpc.Render(bmpLock, offsetX, offsetY, false);
                DrawZoomPicture();
                if (chkChgt.Checked)
                {
                    LigneSplit lSpl = bitmapCpc.splitEcran.GetLigne((int)numLigne.Value);
                    Graphics   g    = Graphics.FromImage(pictureBox.Image);
                    numCol = lSpl.numPen;
                    int xpos = lSpl.retard >> 2;
                    int x    = xpos;
                    XorDrawing.DrawXorLine(g, (Bitmap)pictureBox.Image, x << 3, 0, x << 3, pictureBox.Image.Height);
                    for (int ns = 0; ns < 6; ns++)
                    {
                        Split s = lSpl.GetSplit(ns);
                        if (s.enable)
                        {
                            xpos += s.longueur >> 2;

                            if (xpos > 96)
                            {
                                xpos = 96;
                            }

                            // de x à xpos => faire palette = curPal
                            x = xpos;
                            XorDrawing.DrawXorLine(g, (Bitmap)pictureBox.Image, x << 3, 0, x << 3, pictureBox.Image.Height);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                pictureBox.Refresh();
            }
        }
Beispiel #5
0
        public BitmapCpc(int tx, int ty, int mode)
        {
            nbCol = tx >> 3;
            nbLig = ty >> 1;
            for (int y = 0; y < 272; y++)
            {
                tabMode[y] = mode;
                LigneSplit l = new LigneSplit();
                l.retard = retardMin;
                for (int j = 0; j < 6; j++)
                {
                    l.ListeSplit.Add(new Split());
                }

                splitEcran.LignesSplit.Add(l);
                for (int x = 0; x < 96; x++)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        Palette[x, y, i] = paletteStandardCPC[i];                         // ### a reconstruire avec les splits ?
                    }
                }
            }
        }
Beispiel #6
0
        static public void CreeAsm(StreamWriter wr, BitmapCpc bmp)
        {
            WriteDebFile(wr, 32 + BitmapCpc.retardMin);
            int nbLigneVide = 0;
            int tpsImage = 3;
            int reste = 0;
            int oldc2 = 0, oldc3 = 0, oldc4 = 0, oldc5 = 0, oldc6 = 0, oldPen = 0;

            for (int y = 0; y < 272; y++)
            {
                LigneSplit lSpl = bmp.splitEcran.LignesSplit[y];
                if (lSpl.ListeSplit[0].enable)
                {
                    int retPrec = 0;
                    if (nbLigneVide > 0 || reste > 0)
                    {
                        retPrec     = (reste << 3) + (nbLigneVide * 512);
                        nbLigneVide = 0;
                    }
                    int retard = lSpl.retard - BitmapCpc.retardMin;
                    GenereRetard(wr, retard + retPrec);
                    int retSameCol = 0;
                    wr.WriteLine("; ---- Ligne " + y.ToString() + " ----");
                    if (reste < 0 && lSpl.numPen == oldPen)
                    {
                        GenereRetard(wr, (6 + reste) << 3);
                    }
                    else
                    {
                        wr.WriteLine("	LD	C,"+ lSpl.numPen.ToString() + "			; (2 NOPs)");
                        wr.WriteLine("	OUT	(C),C			; (4 NOPs)");
                        oldPen = lSpl.numPen;
                    }
                    int c1 = CpcVGA[lSpl.ListeSplit[0].couleur];
                    wr.WriteLine("	LD	C,#"+ c1.ToString("X2") + "			; (2 NOPs)");
                    int c2 = CpcVGA[lSpl.ListeSplit[1].couleur];
                    int c3 = CpcVGA[lSpl.ListeSplit[2].couleur];
                    if (c2 != oldc2 || c3 != oldc3)
                    {
                        wr.WriteLine("	LD	DE,#"+ c2.ToString("X2") + c3.ToString("X2") + "		; (3 NOPs)");
                    }
                    else
                    {
                        retSameCol += 24;
                    }

                    int c4 = CpcVGA[lSpl.ListeSplit[3].couleur];
                    int c5 = CpcVGA[lSpl.ListeSplit[4].couleur];
                    if (c4 != oldc4 || c5 != oldc5)
                    {
                        wr.WriteLine("	LD	HL,#"+ c4.ToString("X2") + c5.ToString("X2") + "		; (3 NOPs)");
                    }
                    else
                    {
                        retSameCol += 24;
                    }

                    int c6 = CpcVGA[lSpl.ListeSplit[5].couleur];
                    if (c6 != oldc6)
                    {
                        wr.WriteLine("	LD	A,#"+ c6.ToString("X2") + "			; (2 NOPs)");
                    }
                    else
                    {
                        retSameCol += 16;
                    }

                    if (retSameCol > 0)
                    {
                        GenereRetard(wr, retSameCol);
                    }

                    wr.WriteLine("	OUT	(C),C			; (4 NOPs)");
                    int tpsLine = (retard >> 3) + 20;
                    int lg      = lSpl.ListeSplit[0].longueur - 32;
                    tpsLine += lg >> 3;
                    if (lSpl.ListeSplit[1].enable)
                    {
                        if (lg > 0)
                        {
                            GenereRetard(wr, lg);
                            lg = 0;
                        }
                        wr.WriteLine("	OUT	(C),D			; (4 NOPs)");
                        tpsLine += 4;
                        if (lSpl.ListeSplit[2].enable)
                        {
                            int lgs = lSpl.ListeSplit[1].longueur - 32;
                            GenereRetard(wr, lgs);
                            wr.WriteLine("	OUT	(C),E			; (4 NOPs)");
                            tpsLine += 4 + (lgs >> 3);
                            if (lSpl.ListeSplit[3].enable)
                            {
                                lgs = lSpl.ListeSplit[2].longueur - 32;
                                GenereRetard(wr, lgs);
                                wr.WriteLine("	OUT	(C),H			; (4 NOPs)");
                                tpsLine += 4 + (lgs >> 3);
                                if (lSpl.ListeSplit[4].enable)
                                {
                                    lgs = lSpl.ListeSplit[3].longueur - 32;
                                    GenereRetard(wr, lgs);
                                    wr.WriteLine("	OUT	(C),L			; (4 NOPs)");
                                    tpsLine += 4 + (lgs >> 3);
                                    if (lSpl.ListeSplit[5].enable)
                                    {
                                        lgs = lSpl.ListeSplit[4].longueur - 32;
                                        GenereRetard(wr, lgs);
                                        wr.WriteLine("	OUT	(C),A			; (4 NOPs)");
                                        tpsLine += 4 + (lgs >> 3);
                                    }
                                }
                            }
                        }
                    }
                    oldc2 = c2;
                    oldc3 = c3;
                    oldc4 = c4;
                    oldc5 = c5;
                    oldc6 = c6;
                    reste = 64 - tpsLine + (lg >> 3);
                }
                else
                {
                    nbLigneVide++;
                    wr.WriteLine("; ---- Ligne " + y.ToString() + " (vide) ----");
                }

                tpsImage += 64;
            }
            if (nbLigneVide > 0 || reste > 0)
            {
                tpsImage -= ((nbLigneVide * 64) + reste);
            }

            GenereRetard(wr, (17439 - tpsImage) << 3);
            WriteEndFile(wr, bmp.Palette);
        }
Beispiel #7
0
        private void ValideSplit()
        {
            listErr.Items.Clear();
            int lastLineWrite = 0;

            for (int y = 0; y < 272; y++)
            {
                int        numSplit = 0, longSplit = 0;
                RvbColor   p      = bmpSplit.GetPixelColor(0, y << 1);
                int        curCol = (p.r > SEUIL_LUM_2 ? 6 : p.r > SEUIL_LUM_1 ? 3 : 0) + (p.b > SEUIL_LUM_2 ? 2 : p.b > SEUIL_LUM_1 ? 1 : 0) + (p.v > SEUIL_LUM_2 ? 18 : p.v > SEUIL_LUM_1 ? 9 : 0);
                LigneSplit lSplit = splitEcran.LignesSplit[y];
                for (int i = 0; i < 6; i++)
                {
                    lSplit.ListeSplit[i].enable   = false;
                    lSplit.ListeSplit[i].longueur = 32;
                }

                lSplit.numPen = (int)numPen.Value;
                for (int x = 0; x < 96; x++)
                {
                    int posY = y << 1;
                    int posX = (x << 3) + (BitmapCpc.retardMin << 1);
                    if (posX < 768 && posX >= 0)
                    {
                        p = bmpSplit.GetPixelColor(posX, posY);
                        // Recherche la couleur cpc la plus proche
                        int indexChoix = (p.r > SEUIL_LUM_2 ? 6 : p.r > SEUIL_LUM_1 ? 3 : 0) + (p.b > SEUIL_LUM_2 ? 2 : p.b > SEUIL_LUM_1 ? 1 : 0) + (p.v > SEUIL_LUM_2 ? 18 : p.v > SEUIL_LUM_1 ? 9 : 0);
                        if (indexChoix != curCol && longSplit >= 32)
                        {
                            lSplit.ListeSplit[numSplit].couleur  = curCol;
                            lSplit.ListeSplit[numSplit].longueur = longSplit;
                            lSplit.ListeSplit[numSplit].enable   = true;
                            curCol    = indexChoix;
                            longSplit = 0;
                            if (numSplit++ >= 5)
                            {
                                AddErr("Plus de 6 splits trouvés sur la ligne " + y + ", seulement 6 seront pris en compte.");
                                x = 96;
                            }
                        }
                        else
                        if (indexChoix != curCol && longSplit > 0)
                        {
                            AddErr("Split de longueur inférieure à 32 trouvé sur la ligne " + y + ", la longueur sera ramenée à 32 pixels.");
                        }

                        longSplit += 4;
                    }
                }
                if (numSplit < 6)
                {
                    bool sameLine = y > 0;
                    for (int k = y - 1; k-- > lastLineWrite;)
                    {
                        for (int j = 6; --j >= 0;)
                        {
                            if (splitEcran.LignesSplit[k].ListeSplit[j].enable && splitEcran.LignesSplit[k].ListeSplit[j].couleur != curCol)
                            {
                                sameLine = false;
                                break;
                            }
                        }
                        if (!sameLine)
                        {
                            break;
                        }
                    }
                    if (longSplit >= 32 && (y == 0 || numSplit > 0 || !sameLine))
                    {
                        lSplit.ListeSplit[numSplit].couleur  = curCol;
                        lSplit.ListeSplit[numSplit].longueur = longSplit;
                        lSplit.ListeSplit[numSplit].enable   = true;
                        lastLineWrite = y;
                    }
                }
            }
        }