-
Notifications
You must be signed in to change notification settings - Fork 0
/
c2p_carddelta.c
257 lines (223 loc) · 6.84 KB
/
c2p_carddelta.c
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/* :ts=4 c2p_carddelta.c
*
* cp4 - Commodore C+4 emulator
* Copyright (C) 1998 Gáti Gergely
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* e-mail: [email protected]
*/
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <exec/memory.h>
#include "cp4_ver.h"
#define C2P_VERSION "1"
#define C2P_REVISION "1"
#define C2P_AUTHOR "gega <Gáti Gergely>"
#define C2P_NAME "CardDelta"
#define C2P_BUFFERING 3
#define C2P_DATE DATE
#define C2P_LOCALIZE
#include "c2p_module.c"
#include "c2p_palette.c"
extern void carddelta( REG(a0,void *rp),
REG(a1,void *temprp),
REG(d0,void *chunky),
REG(d1,void *delta));
struct GfxBase *GfxBase=NULL;
struct IntuitionBase *IntuitionBase=NULL;
static struct BitMap *bmapwpx;
static struct RastPort *tmpraswpx;
static struct RastPort *raswpx;
static struct ScreenBuffer *scrb[3];
static UWORD *nopointer=NULL;
static struct Screen *scr=NULL;
static struct Window *win=NULL;
static int winsleeped=0;
static struct Requester InvisibleRequester;
static ULONG Palette8[770];
#define MSG_INFO 0
#define MSG_NOSCRMODE 1
#define MSG_NOGFX 2
#define MSG_NOINTUI 3
#define MSG_NOSCR 4
#define MSG_NOWIN 5
#define MSG_NOMEM 6
#define MSG_NOHAMEHB 7
static char *defstr[]={
"This is an enhanced driver for graphics cards. It's working on AGA too, but it's use the WritePixelLine8() function, and it's deadly slow on AGA.",
"No ScreenMode Specified",
"Can't open graphics.library V39",
"Can't open intuition.library V39",
"Can't open Screen",
"Can't open Window",
"Not enough memory",
"EHB and HAM isn't supported",
NULL
};
char *SAVEDS minfo(void) {
static char in[1024];
char *s;
c2p_OpenCatalog(defstr);
s=STR(MSG_INFO);
c2p_strncpy(in,s,1023);
c2p_CloseCatalog();
return(in);
}
char *SAVEDS minit(ULONG scrmode, ULONG overscan, unsigned char *linedeltatab) {
int planes=8,i;
c2p_OpenCatalog(defstr);
if(scrmode==~0) return(STR(MSG_NOSCRMODE));
if((scrmode&0x880)!=0) return(STR(MSG_NOHAMEHB));
/* Allocate mem for nopointer
*/
if(NULL==(nopointer=AllocVec(24,MEMF_CHIP|MEMF_CLEAR))) return(STR(MSG_NOMEM));
/* Create palette
*/
if(vec.c2p_Palette!=NULL) {
ULONG *p,l;
p=Palette;
for(p+=1,i=0;i<384;) {
l=0;
l=(vec.c2p_Palette[i]<<8)|vec.c2p_Palette[i];
l|=(l<<16);
*p++=l;
i++;
l=(vec.c2p_Palette[i]<<8)|vec.c2p_Palette[i];
l|=(l<<16);
*p++=l;
i++;
l=(vec.c2p_Palette[i]<<8)|vec.c2p_Palette[i];
l|=(l<<16);
*p++=l;
i++;
}
}
Palette8[0]=256<<16;
for(i=0;i<384;i++) Palette8[1+i]=Palette[1+i];
for(i=0;i<384;i++) Palette8[1+i+384]=Palette[1+i];
if((GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39))==NULL) return(STR(MSG_NOGFX));
if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39))) return(STR(MSG_NOINTUI));
/* Allocate bitmaps
*/
bmapwpx=AllocBitMap(SCRWIDTH,1,8,BMF_CLEAR,NULL);
if(bmapwpx==NULL) return(STR(MSG_NOMEM));
tmpraswpx=AllocVec(sizeof(struct RastPort),MEMF_ANY);
if(tmpraswpx==NULL) return(STR(MSG_NOMEM));
InitRastPort(tmpraswpx);
tmpraswpx->BitMap=bmapwpx;
raswpx=AllocVec(sizeof(struct RastPort),MEMF_ANY);
if(raswpx==NULL) return(STR(MSG_NOMEM));
InitRastPort(raswpx);
/* Open Screen
*/
if(NULL==(scr=OpenScreenTags(NULL,
SA_DisplayID, scrmode,
SA_Depth, planes,
SA_ShowTitle,FALSE,
SA_Quiet, TRUE,
SA_Width, SCRWIDTH,
SA_Height, SCRHEIGHT,
SA_Behind, TRUE,
SA_Colors32, (ULONG)Palette,
SA_Overscan, overscan,
SA_Type, CUSTOMSCREEN,
TAG_DONE,0L )))
return(STR(MSG_NOSCR));
vec.c2p_Scr=scr;
/* Open window
*/
if((win=(struct Window *)OpenWindowTags(NULL,
WA_NoCareRefresh, TRUE,
WA_Activate, TRUE,
WA_Borderless, TRUE,
WA_Backdrop, TRUE,
WA_CustomScreen, (ULONG)scr,
WA_RMBTrap, TRUE,
WA_RptQueue, 25,
TAG_DONE,0L ))==NULL)
return(STR(MSG_NOWIN));
vec.c2p_Win=win;
winsleeped=0;
/* set nopointer
*/
SetPointer(win,nopointer,1,16,0,0);
/* Allocate screen buffers
*/
scrb[0]=AllocScreenBuffer(scr,NULL,NULL);
scrb[1]=AllocScreenBuffer(scr,NULL,NULL);
scrb[2]=AllocScreenBuffer(scr,NULL,NULL);
if(scrb[0]==NULL||scrb[1]==NULL||scrb[2]==NULL) return(STR(MSG_NOMEM));
scrb[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
scrb[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=NULL;
scrb[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
scrb[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=NULL;
scrb[2]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
scrb[2]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=NULL;
return(NULL);
} // init
void SAVEDS mfree(void) {
mawake();
if(GfxBase) WaitTOF();
if(scrb[0]) { FreeScreenBuffer(scr,scrb[0]); scrb[0]=NULL; }
if(scrb[1]) { FreeScreenBuffer(scr,scrb[1]); scrb[1]=NULL; }
if(scrb[2]) { FreeScreenBuffer(scr,scrb[2]); scrb[2]=NULL; }
if(win) ClearPointer(win);
if(nopointer) { FreeVec(nopointer); nopointer=NULL; }
if(win) { CloseWindow(win); win=NULL; }
vec.c2p_Win=NULL;
if(scr) { CloseScreen(scr); scr=NULL; }
vec.c2p_Scr=NULL;
if(bmapwpx) FreeBitMap(bmapwpx);
if(tmpraswpx) FreeVec(tmpraswpx);
if(raswpx) FreeVec(raswpx);
if(GfxBase) CloseLibrary((struct Library *)GfxBase);
if(IntuitionBase) { CloseLibrary((struct Library *)IntuitionBase); IntuitionBase=NULL; }
c2p_CloseCatalog();
} // free
int SAVEDS mdo(unsigned char *chunky,unsigned char *delta,int numscreen) {
raswpx->BitMap=scrb[numscreen]->sb_BitMap;
carddelta(raswpx,tmpraswpx,chunky,delta);
ChangeScreenBuffer(scr,scrb[numscreen]);
return(RET_OK);
} // do
int SAVEDS mdofull(unsigned char *chunky,int numscreen) {
raswpx->BitMap=scrb[numscreen]->sb_BitMap;
WritePixelArray8(raswpx,0,0,SCRWIDTH-1,SCRHEIGHT-1,chunky,tmpraswpx);
ChangeScreenBuffer(scr,scrb[numscreen]);
return(RET_OK);
} // dofull
int SAVEDS mdont(void) {
return(RET_OK);
} // dont
void SAVEDS msleep(void) {
if(win) {
InitRequester(&InvisibleRequester);
Request(&InvisibleRequester,win);
SetWindowPointer(win,WA_BusyPointer,TRUE,TAG_DONE);
winsleeped=1;
}
}
void SAVEDS mawake(void) {
if(winsleeped) {
if(win) {
EndRequest(&InvisibleRequester,win);
SetWindowPointerA(win,NULL);
SetPointer(win,nopointer,1,16,0,0);
winsleeped=0;
}
}
}