scale.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //---------------------------------------------------------------------------//
  2. // scale.cpp - This file contains definitions of the scaleFactor for scaled draws
  3. //
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. //---------------------------------------------------------------------------
  8. // Include files
  9. #ifndef DSTD_H
  10. #include "dstd.h"
  11. #endif
  12. #ifndef HEAP_H
  13. #include "heap.h"
  14. #endif
  15. #ifndef VPORT_H
  16. #include "vport.h"
  17. #endif
  18. #ifndef VFX_H
  19. #include "vfx.h"
  20. #endif
  21. #ifndef CAMERA_H
  22. #include "camera.h"
  23. #endif
  24. #include <math.h>
  25. #include <gameos.hpp>
  26. extern void AG_shape_translate_transform(PANE *globalPane, void *shapeTable,LONG frameNum, LONG hotX, LONG hotY,void *tempBuffer,LONG reverse, LONG scaleUp);
  27. extern void AG_shape_transform(PANE *globalPane, void *shapeTable,LONG frameNum, LONG hotX, LONG hotY, void *tempBuffer,LONG reverse, LONG scaleUp);
  28. extern void AG_shape_lookaside( UBYTE *table );
  29. extern void AG_shape_draw (PANE *pane, void *shape_table,LONG shape_number, LONG hotX, LONG hotY);
  30. extern void AG_shape_translate_draw (PANE *pane, void *shape_table,LONG shape_number, LONG hotX, LONG hotY);
  31. //---------------------------------------------------------------------------
  32. #define MAX_X 360
  33. #define MAX_Y 360
  34. MemoryPtr tempBuffer = NULL;
  35. //---------------------------------------------------------------------------
  36. //
  37. long scaleDraw (MemoryPtr shapeTable, unsigned long frameNum, long sx, long sy, bool reverse, MemoryPtr fadeTable, bool scaleUp)
  38. {
  39. //--------------------------------------------------------------
  40. // Check GlobalPane and GlobalWindow for validity.
  41. if( Camera::globalScaleFactor==1.0 )
  42. scaleUp=1;
  43. else
  44. scaleUp=0;
  45. //----------------------------------------------------------------
  46. // Check if shape is actually valid.
  47. if ((*(int*)shapeTable!=*(int*)"1.10"))
  48. return(TRUE);
  49. long result = VFX_shape_count(shapeTable);
  50. if (result <= (long)frameNum)
  51. {
  52. frameNum = result-1;
  53. }
  54. result = VFX_shape_bounds(shapeTable,frameNum);
  55. long xMax = result>>16;
  56. long yMax = result & 0x0000ffff;
  57. if ((xMax == 0) || (yMax == 0))
  58. return -1;
  59. if (abs(xMax - yMax) > 256)
  60. {
  61. return -1;
  62. }
  63. if ((xMax > 400) || (yMax > 400))
  64. {
  65. return -1;
  66. }
  67. if (!tempBuffer)
  68. tempBuffer = (MemoryPtr)systemHeap->Malloc(MAX_X * MAX_Y);
  69. gosASSERT((yMax * xMax) < (MAX_Y * MAX_X));
  70. if (fadeTable)
  71. {
  72. AG_shape_lookaside(fadeTable);
  73. if(scaleUp && !reverse)
  74. AG_shape_translate_draw(globalPane,shapeTable,frameNum,sx,sy);
  75. else
  76. AG_shape_translate_transform(globalPane,shapeTable,frameNum,sx,sy,tempBuffer,reverse,scaleUp);
  77. }
  78. else
  79. {
  80. if(scaleUp && !reverse)
  81. AG_shape_draw(globalPane,shapeTable,frameNum,sx,sy);
  82. else
  83. AG_shape_transform(globalPane,shapeTable,frameNum,sx,sy,tempBuffer,reverse,scaleUp);
  84. }
  85. return(result);
  86. }
  87. //---------------------------------------------------------------------------