-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathUnrestricted.cpp
145 lines (116 loc) · 3.08 KB
/
Unrestricted.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
Pixcen - A windows platform low level pixel editor for C64
Copyright (C) 2013 John Hammarberg ([email protected])
This file is part of Pixcen.
Pixcen is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Pixcen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Pixcen. If not, see <http://www.gnu.org/licenses/>.
*/
#include "StdAfx.h"
#include "C64Interface.h"
Unrestricted::Unrestricted(int x, int y, bool wide, int backbuffers)
{
if(wide)
{
mode = W_UNRESTRICTED;
offsetcell=xcell=4;
}
else
{
mode = UNRESTRICTED;
offsetcell=xcell=8;
}
xsize=x;
ysize=y;
ycell=8;
Create(x*y, 0, 0, backbuffers);
}
Unrestricted::~Unrestricted()
{
}
void Unrestricted::GetSaveFormats(narray<autoptr<SaveFormat>,int> &fmt)
{
__super::GetSaveFormats(fmt);
//fmt.add(new SaveFormat(_T("Assembler"),_T("s")));
//fmt.add(new SaveFormat(_T("Binary"),_T("raw"),false));
}
void Unrestricted::GetLoadFormats(narray<autoptr<SaveFormat>,int> &fmt)
{
}
void Unrestricted::Save(nmemfile &file, LPCTSTR type)
{
if(lstrcmpi(_T("map"),type)==0)
{
BYTE b;
int x,y;
for(y=0;y<ysize;y++)
{
for(x=0;x<xsize;x++)
{
b=GetPixel(x,y)&0x0f;
b = b | (b<<4);
file << b;
}
}
}
else __super::Save(file,type);
}
BYTE Unrestricted::GetPixelInternal(int x, int y)
{
ASSERT(x>=0 && x<xsize && y>=0 && y<ysize);
return map[y*xsize+x];
}
BYTE Unrestricted::GetPixel(int x, int y)
{
return GetPixelInternal(x, y);
}
void Unrestricted::SetPixel(int x, int y, BYTE col)
{
ASSERT(x>=0 && x<xsize && y>=0 && y<ysize);
map[y*xsize+x] = (col&0x0f);
}
void Unrestricted::GetCellInfo(int cx, int cy, int w, int h, CellInfo *info)
{
info->h = 8;
info->w = 8 / GetPixelWidth();
info->col[0]=info->col[1]=info->col[2]=info->col[3]=info->col[4]=0xff;
C64Interface::GetCellInfo(cx, cy, w, h, info);
}
void Unrestricted::Import(CImage &img)
{
ClearBackBuffer();
{
ImportHelper help(this, img, mode == W_UNRESTRICTED ? true : false);
}
*border = GuessBorderColor();
}
C64Interface *Unrestricted::CreateFromSelection(int x, int y, int w, int h)
{
Unrestricted *i = NULL;
if(mode == UNRESTRICTED)
{
i = new class Unrestricted(w, h, false, 1);
}
else
{
assert(mode == W_UNRESTRICTED);
i = new class Unrestricted(w, h, true, 1);
}
for (int cy = 0; cy<h; cy++)
{
for (int cx = 0; cx<w; cx++)
{
i->map[w*cy + cx] = map[xsize*(y + cy) + (x + cx)];
}
}
//Other data, global colors, locks, etc, 64 bytes before map pointer
memcpy(i->map - 64, map - 64, 64);
return i;
}