summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-03-18 20:02:21 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2011-03-18 20:14:19 (GMT)
commitf316b1fdb927f2ca1c20a5ae58611d6c2cf6d442 (patch)
treeb77b0f67a29b20c556dccc01e0db76114c972096 /src
parentd46a3bdcb083075a4737125f1c71899e6489ecfa (diff)
downloadpowder-f316b1fdb927f2ca1c20a5ae58611d6c2cf6d442.zip
powder-f316b1fdb927f2ca1c20a5ae58611d6c2cf6d442.tar.gz
Remove redundant rotate/invert code and correct rotation direction
Diffstat (limited to 'src')
-rw-r--r--src/main.c27
-rw-r--r--src/powder.c84
2 files changed, 2 insertions, 109 deletions
diff --git a/src/main.c b/src/main.c
index 5f5e7a4..7f49d9b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1810,7 +1810,7 @@ int main(int argc, char *argv[])
}
else if (sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
{
- transform = m2d_new(0,-1,1,0); //rotate anticlockwise 90 degrees
+ transform = m2d_new(0,1,-1,0); //rotate anticlockwise 90 degrees
doTransform = 1;
}
else if (sdl_mod & (KMOD_CTRL))
@@ -2227,22 +2227,6 @@ int main(int argc, char *argv[])
copy_mode = 0;
clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
}
- else if (copy_mode==3)//rotation
- {
- if (save_h>save_w)
- save_w = save_h;
- rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,0);//just do squares for now
- save_mode = 0;
- copy_mode = 0;
- }
- else if (copy_mode==4)//invertion
- {
- if (save_h>save_w)
- save_w = save_h;
- rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,1);//just do squares for now
- save_mode = 0;
- copy_mode = 0;
- }
else
{
stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
@@ -2564,14 +2548,7 @@ int main(int argc, char *argv[])
if (save_mode)
{
- if (copy_mode==3||copy_mode==4)//special drawing for rotate, can remove once it can do rectangles
- {
- if (save_h>save_w)
- save_w = save_h;
- xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL);
- }
- else
- xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
+ xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL);
da = 51;
db = 269;
}
diff --git a/src/powder.c b/src/powder.c
index fc73276..7e26422 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -2590,90 +2590,6 @@ void update_particles(pixel *vid)
}
-void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
-{
- //TODO: MSCC doesn't like arrays who's size is determined at runtime.
-#if !(defined(WIN32) && !defined(__GNUC__))
- int cx = 0;
- int cy = 0;
- unsigned tpmap[area_h][area_w];
- unsigned rtpmap[area_w][area_h];
- unsigned char tbmap[area_h/CELL][area_w/CELL];
- unsigned char rtbmap[area_w/CELL][area_h/CELL];
- float tfvy[area_h/CELL][area_w/CELL];
- float tfvx[area_h/CELL][area_w/CELL];
- for (cy=0; cy<area_h; cy++)
- {
- for (cx=0; cx<area_w; cx++)//save walls to temp
- {
- if (area_x + cx<XRES&&area_y + cy<YRES)
- {
- if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]) {
- tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
- if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]==WL_FAN) {
- tfvx[cy/CELL][cx/CELL] = fvx[(cy+area_y)/CELL][(cx+area_x)/CELL];
- tfvy[cy/CELL][cx/CELL] = fvy[(cy+area_y)/CELL][(cx+area_x)/CELL];
- }
- } else {
- tbmap[cy/CELL][cx/CELL] = 0;
- tfvx[cy/CELL][cx/CELL] = 0;
- tfvy[cy/CELL][cx/CELL] = 0;
- }
- }
- }
- }
- for (cy=0; cy<area_h; cy++)
- {
- for (cx=0; cx<area_w; cx++)//save particles to temp
- {
- if ((area_x + cx<XRES&&area_y + cy<YRES))
- {
- tpmap[cy][cx] = pmap[(int)(cy+area_y+0.5f)][(int)(cx+area_x+0.5f)];
- }
- else
- tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)] = 0;
- }
- }
- for (cy=0; cy<area_w; cy++)
- {
- for (cx=0; cx<area_h; cx++)//rotate temp arrays
- {
- if (invert)
- {
- rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
- rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
- tfvx[cy/CELL][((area_h-1)-cx)/CELL] = -tfvx[cy/CELL][cx/CELL];
- tfvy[cy/CELL][((area_h-1)-cx)/CELL] = tfvy[cy/CELL][cx/CELL];
- }
- else
- {
- rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
- rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
- tfvy[((area_h-1)-cx)/CELL][cy/CELL] = -tfvx[cy/CELL][cx/CELL];
- tfvx[((area_h-1)-cx)/CELL][cy/CELL] = tfvy[cy/CELL][cx/CELL];
- }
- }
- }
- for (cy=0; cy<area_w; cy++)
- {
- for (cx=0; cx<area_h; cx++)//move particles and walls
- {
- if (area_x + cx<XRES&&area_y + cy<YRES)
- {
- if ((rtpmap[cy][cx]>>8)<=NPART&&rtpmap[cy][cx])
- {
- parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx;
- parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
- }
- bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
- fvy[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvy[cy/CELL][cx/CELL];
- fvx[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvx[cy/CELL][cx/CELL];
- }
- }
- }
-#endif
-}
-
void clear_area(int area_x, int area_y, int area_w, int area_h)
{
int cx = 0;