annotate src/win32/GBOamView.cpp @ 2:3549bbe597ed

adding makefile.am
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:47 -0600
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 // GBOamView.cpp : implementation file
rlm@1 2 //
rlm@1 3
rlm@1 4 #include "stdafx.h"
rlm@1 5 #include "resource.h"
rlm@1 6 #include "GBOamView.h"
rlm@1 7 #include "FileDlg.h"
rlm@1 8 #include "Reg.h"
rlm@1 9 #include "WinResUtil.h"
rlm@1 10 #include "VBA.h"
rlm@1 11
rlm@1 12 //#include "../common/System.h"
rlm@1 13 #include "../gb/gbGlobals.h"
rlm@1 14 #include "../NLS.h"
rlm@1 15 #include "../common/Util.h"
rlm@1 16
rlm@1 17 extern "C" {
rlm@1 18 #include <png.h>
rlm@1 19 }
rlm@1 20
rlm@1 21 /////////////////////////////////////////////////////////////////////////////
rlm@1 22 // GBOamView dialog
rlm@1 23
rlm@1 24 GBOamView::GBOamView(CWnd*pParent /*=NULL*/)
rlm@1 25 : ResizeDlg(GBOamView::IDD, pParent)
rlm@1 26 {
rlm@1 27 //{{AFX_DATA_INIT(GBOamView)
rlm@1 28 m_stretch = FALSE;
rlm@1 29 //}}AFX_DATA_INIT
rlm@1 30 autoUpdate = false;
rlm@1 31
rlm@1 32 memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader));
rlm@1 33
rlm@1 34 bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader);
rlm@1 35 bmpInfo.bmiHeader.biWidth = 8;
rlm@1 36 bmpInfo.bmiHeader.biHeight = 16;
rlm@1 37 bmpInfo.bmiHeader.biPlanes = 1;
rlm@1 38 bmpInfo.bmiHeader.biBitCount = 24;
rlm@1 39 bmpInfo.bmiHeader.biCompression = BI_RGB;
rlm@1 40 data = (u8 *)calloc(1, 3 * 8 * 16);
rlm@1 41
rlm@1 42 oamView.setData(data);
rlm@1 43 oamView.setBmpInfo(&bmpInfo);
rlm@1 44
rlm@1 45 number = 0;
rlm@1 46 }
rlm@1 47
rlm@1 48 void GBOamView::DoDataExchange(CDataExchange*pDX)
rlm@1 49 {
rlm@1 50 CDialog::DoDataExchange(pDX);
rlm@1 51 //{{AFX_DATA_MAP(GBOamView)
rlm@1 52 DDX_Control(pDX, IDC_SPRITE, m_sprite);
rlm@1 53 DDX_Check(pDX, IDC_STRETCH, m_stretch);
rlm@1 54 //}}AFX_DATA_MAP
rlm@1 55 DDX_Control(pDX, IDC_COLOR, color);
rlm@1 56 DDX_Control(pDX, IDC_OAM_VIEW, oamView);
rlm@1 57 DDX_Control(pDX, IDC_OAM_VIEW_ZOOM, oamZoom);
rlm@1 58 }
rlm@1 59
rlm@1 60 BEGIN_MESSAGE_MAP(GBOamView, CDialog)
rlm@1 61 //{{AFX_MSG_MAP(GBOamView)
rlm@1 62 ON_BN_CLICKED(IDC_STRETCH, OnStretch)
rlm@1 63 ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
rlm@1 64 ON_EN_CHANGE(IDC_SPRITE, OnChangeSprite)
rlm@1 65 ON_BN_CLICKED(IDC_CLOSE, OnClose)
rlm@1 66 ON_WM_HSCROLL()
rlm@1 67 //}}AFX_MSG_MAP
rlm@1 68 ON_MESSAGE(WM_MAPINFO, OnMapInfo)
rlm@1 69 ON_MESSAGE(WM_COLINFO, OnColInfo)
rlm@1 70 END_MESSAGE_MAP()
rlm@1 71
rlm@1 72 /////////////////////////////////////////////////////////////////////////////
rlm@1 73 // GBOamView message handlers
rlm@1 74
rlm@1 75 GBOamView::~GBOamView()
rlm@1 76 {
rlm@1 77 free(data);
rlm@1 78 data = NULL;
rlm@1 79 }
rlm@1 80
rlm@1 81 void GBOamView::paint()
rlm@1 82 {
rlm@1 83 if (gbRom == NULL)
rlm@1 84 return;
rlm@1 85
rlm@1 86 render();
rlm@1 87 oamView.setSize(w, h);
rlm@1 88 oamView.refresh();
rlm@1 89 }
rlm@1 90
rlm@1 91 void GBOamView::update()
rlm@1 92 {
rlm@1 93 paint();
rlm@1 94 }
rlm@1 95
rlm@1 96 void GBOamView::setAttributes(int y, int x, int tile, int flags)
rlm@1 97 {
rlm@1 98 CString buffer;
rlm@1 99
rlm@1 100 int flipH = flags & 0x20;
rlm@1 101 int flipV = flags & 0x40;
rlm@1 102 int prio = (flags & 0x80) >> 7;
rlm@1 103 int pal = flags & 0x7;
rlm@1 104 int oap = (flags & 0x08) >> 3;
rlm@1 105 int bank = (flags & 0x10) >> 4;
rlm@1 106
rlm@1 107 buffer.Format("%d,%d", x, y);
rlm@1 108 GetDlgItem(IDC_POS)->SetWindowText(buffer);
rlm@1 109
rlm@1 110 buffer.Format("%d", pal);
rlm@1 111 GetDlgItem(IDC_PALETTE)->SetWindowText(buffer);
rlm@1 112
rlm@1 113 buffer.Format("%d", tile);
rlm@1 114 GetDlgItem(IDC_TILE)->SetWindowText(buffer);
rlm@1 115
rlm@1 116 buffer.Format("%d", prio);
rlm@1 117 GetDlgItem(IDC_PRIO)->SetWindowText(buffer);
rlm@1 118
rlm@1 119 buffer.Format("%d", bank);
rlm@1 120 GetDlgItem(IDC_BANK)->SetWindowText(buffer);
rlm@1 121
rlm@1 122 buffer.Empty();
rlm@1 123 if (flipH)
rlm@1 124 buffer += 'H';
rlm@1 125 else
rlm@1 126 buffer += ' ';
rlm@1 127 if (flipV)
rlm@1 128 buffer += 'V';
rlm@1 129 else
rlm@1 130 buffer += ' ';
rlm@1 131 GetDlgItem(IDC_FLAGS)->SetWindowText(buffer);
rlm@1 132
rlm@1 133 buffer.Format("%d", oap);
rlm@1 134 GetDlgItem(IDC_OAP)->SetWindowText(buffer);
rlm@1 135 }
rlm@1 136
rlm@1 137 void GBOamView::render()
rlm@1 138 {
rlm@1 139 int m = 0;
rlm@1 140 if (gbRom == NULL)
rlm@1 141 return;
rlm@1 142
rlm@1 143 u16 addr = number * 4 + 0xfe00;
rlm@1 144
rlm@1 145 int size = register_LCDC & 4;
rlm@1 146
rlm@1 147 u8 y = gbReadMemoryQuick(addr++);
rlm@1 148 u8 x = gbReadMemoryQuick(addr++);
rlm@1 149 u8 tile = gbReadMemoryQuick(addr++);
rlm@1 150 if (size)
rlm@1 151 tile &= 254;
rlm@1 152 u8 flags = gbReadMemoryQuick(addr++);
rlm@1 153
rlm@1 154 u8 *bmp = data;
rlm@1 155
rlm@1 156 w = 8;
rlm@1 157 h = size ? 16 : 8;
rlm@1 158
rlm@1 159 setAttributes(y, x, tile, flags);
rlm@1 160
rlm@1 161 u8 *bank0;
rlm@1 162 u8 *bank1;
rlm@1 163 if (gbCgbMode)
rlm@1 164 {
rlm@1 165 if (register_VBK & 1)
rlm@1 166 {
rlm@1 167 bank0 = &gbVram[0x0000];
rlm@1 168 bank1 = &gbVram[0x2000];
rlm@1 169 }
rlm@1 170 else
rlm@1 171 {
rlm@1 172 bank0 = &gbVram[0x0000];
rlm@1 173 bank1 = &gbVram[0x2000];
rlm@1 174 }
rlm@1 175 }
rlm@1 176 else
rlm@1 177 {
rlm@1 178 bank0 = &gbMemory[0x8000];
rlm@1 179 bank1 = NULL;
rlm@1 180 }
rlm@1 181
rlm@1 182 int init = 0x0000;
rlm@1 183
rlm@1 184 u8 *pal = gbObp0;
rlm@1 185
rlm@1 186 if ((flags & 0x10))
rlm@1 187 pal = gbObp1;
rlm@1 188
rlm@1 189 for (int yy = 0; yy < h; yy++)
rlm@1 190 {
rlm@1 191 int address = init + tile * 16 + 2*yy;
rlm@1 192 int a = 0;
rlm@1 193 int b = 0;
rlm@1 194
rlm@1 195 if (gbCgbMode && flags & 0x08)
rlm@1 196 {
rlm@1 197 a = bank1[address++];
rlm@1 198 b = bank1[address++];
rlm@1 199 }
rlm@1 200 else
rlm@1 201 {
rlm@1 202 a = bank0[address++];
rlm@1 203 b = bank0[address++];
rlm@1 204 }
rlm@1 205
rlm@1 206 for (int xx = 0; xx < 8; xx++)
rlm@1 207 {
rlm@1 208 u8 mask = 1 << (7-xx);
rlm@1 209 u8 c = 0;
rlm@1 210 if ((a & mask))
rlm@1 211 c++;
rlm@1 212 if ((b & mask))
rlm@1 213 c += 2;
rlm@1 214
rlm@1 215 // make sure that sprites will work even in CGB mode
rlm@1 216 if (gbCgbMode)
rlm@1 217 {
rlm@1 218 c = c + (flags & 0x07)*4 + 32;
rlm@1 219 }
rlm@1 220 else
rlm@1 221 {
rlm@1 222 c = pal[c];
rlm@1 223 }
rlm@1 224
rlm@1 225 u16 color = gbPalette[c];
rlm@1 226 *bmp++ = ((color >> 10) & 0x1f) << 3;
rlm@1 227 *bmp++ = ((color >> 5) & 0x1f) << 3;
rlm@1 228 *bmp++ = (color & 0x1f) << 3;
rlm@1 229 }
rlm@1 230 }
rlm@1 231 }
rlm@1 232
rlm@1 233 void GBOamView::saveBMP(const char *name)
rlm@1 234 {
rlm@1 235 u8 writeBuffer[1024 * 3];
rlm@1 236
rlm@1 237 FILE *fp = fopen(name, "wb");
rlm@1 238
rlm@1 239 if (!fp)
rlm@1 240 {
rlm@1 241 systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
rlm@1 242 return;
rlm@1 243 }
rlm@1 244
rlm@1 245 struct
rlm@1 246 {
rlm@1 247 u8 ident[2];
rlm@1 248 u8 filesize[4];
rlm@1 249 u8 reserved[4];
rlm@1 250 u8 dataoffset[4];
rlm@1 251 u8 headersize[4];
rlm@1 252 u8 width[4];
rlm@1 253 u8 height[4];
rlm@1 254 u8 planes[2];
rlm@1 255 u8 bitsperpixel[2];
rlm@1 256 u8 compression[4];
rlm@1 257 u8 datasize[4];
rlm@1 258 u8 hres[4];
rlm@1 259 u8 vres[4];
rlm@1 260 u8 colors[4];
rlm@1 261 u8 importantcolors[4];
rlm@1 262 u8 pad[2];
rlm@1 263 } bmpheader;
rlm@1 264 memset(&bmpheader, 0, sizeof(bmpheader));
rlm@1 265
rlm@1 266 bmpheader.ident[0] = 'B';
rlm@1 267 bmpheader.ident[1] = 'M';
rlm@1 268
rlm@1 269 u32 fsz = sizeof(bmpheader) + w*h*3;
rlm@1 270 utilPutDword(bmpheader.filesize, fsz);
rlm@1 271 utilPutDword(bmpheader.dataoffset, 0x38);
rlm@1 272 utilPutDword(bmpheader.headersize, 0x28);
rlm@1 273 utilPutDword(bmpheader.width, w);
rlm@1 274 utilPutDword(bmpheader.height, h);
rlm@1 275 utilPutDword(bmpheader.planes, 1);
rlm@1 276 utilPutDword(bmpheader.bitsperpixel, 24);
rlm@1 277 utilPutDword(bmpheader.datasize, 3*w*h);
rlm@1 278
rlm@1 279 fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
rlm@1 280
rlm@1 281 u8 *b = writeBuffer;
rlm@1 282
rlm@1 283 int sizeX = w;
rlm@1 284 int sizeY = h;
rlm@1 285
rlm@1 286 u8 *pixU8 = (u8 *)data+3*w*(h-1);
rlm@1 287 for (int y = 0; y < sizeY; y++)
rlm@1 288 {
rlm@1 289 for (int x = 0; x < sizeX; x++)
rlm@1 290 {
rlm@1 291 *b++ = *pixU8++; // B
rlm@1 292 *b++ = *pixU8++; // G
rlm@1 293 *b++ = *pixU8++; // R
rlm@1 294 }
rlm@1 295 pixU8 -= 2*3*w;
rlm@1 296 fwrite(writeBuffer, 1, 3*w, fp);
rlm@1 297
rlm@1 298 b = writeBuffer;
rlm@1 299 }
rlm@1 300
rlm@1 301 fclose(fp);
rlm@1 302 }
rlm@1 303
rlm@1 304 void GBOamView::savePNG(const char *name)
rlm@1 305 {
rlm@1 306 u8 writeBuffer[1024 * 3];
rlm@1 307
rlm@1 308 FILE *fp = fopen(name, "wb");
rlm@1 309
rlm@1 310 if (!fp)
rlm@1 311 {
rlm@1 312 systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name);
rlm@1 313 return;
rlm@1 314 }
rlm@1 315
rlm@1 316 png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
rlm@1 317 NULL,
rlm@1 318 NULL,
rlm@1 319 NULL);
rlm@1 320 if (!png_ptr)
rlm@1 321 {
rlm@1 322 fclose(fp);
rlm@1 323 return;
rlm@1 324 }
rlm@1 325
rlm@1 326 png_infop info_ptr = png_create_info_struct(png_ptr);
rlm@1 327
rlm@1 328 if (!info_ptr)
rlm@1 329 {
rlm@1 330 png_destroy_write_struct(&png_ptr, NULL);
rlm@1 331 fclose(fp);
rlm@1 332 return;
rlm@1 333 }
rlm@1 334
rlm@1 335 if (setjmp(png_ptr->jmpbuf))
rlm@1 336 {
rlm@1 337 png_destroy_write_struct(&png_ptr, NULL);
rlm@1 338 fclose(fp);
rlm@1 339 return;
rlm@1 340 }
rlm@1 341
rlm@1 342 png_init_io(png_ptr, fp);
rlm@1 343
rlm@1 344 png_set_IHDR(png_ptr,
rlm@1 345 info_ptr,
rlm@1 346 w,
rlm@1 347 h,
rlm@1 348 8,
rlm@1 349 PNG_COLOR_TYPE_RGB,
rlm@1 350 PNG_INTERLACE_NONE,
rlm@1 351 PNG_COMPRESSION_TYPE_DEFAULT,
rlm@1 352 PNG_FILTER_TYPE_DEFAULT);
rlm@1 353
rlm@1 354 png_write_info(png_ptr, info_ptr);
rlm@1 355
rlm@1 356 u8 *b = writeBuffer;
rlm@1 357
rlm@1 358 int sizeX = w;
rlm@1 359 int sizeY = h;
rlm@1 360
rlm@1 361 u8 *pixU8 = (u8 *)data;
rlm@1 362 for (int y = 0; y < sizeY; y++)
rlm@1 363 {
rlm@1 364 for (int x = 0; x < sizeX; x++)
rlm@1 365 {
rlm@1 366 int blue = *pixU8++;
rlm@1 367 int green = *pixU8++;
rlm@1 368 int red = *pixU8++;
rlm@1 369
rlm@1 370 *b++ = red;
rlm@1 371 *b++ = green;
rlm@1 372 *b++ = blue;
rlm@1 373 }
rlm@1 374 png_write_row(png_ptr, writeBuffer);
rlm@1 375
rlm@1 376 b = writeBuffer;
rlm@1 377 }
rlm@1 378
rlm@1 379 png_write_end(png_ptr, info_ptr);
rlm@1 380
rlm@1 381 png_destroy_write_struct(&png_ptr, &info_ptr);
rlm@1 382
rlm@1 383 fclose(fp);
rlm@1 384 }
rlm@1 385
rlm@1 386 void GBOamView::save()
rlm@1 387 {
rlm@1 388 CString captureBuffer;
rlm@1 389
rlm@1 390 if (theApp.captureFormat == 0)
rlm@1 391 captureBuffer = "oam.png";
rlm@1 392 else
rlm@1 393 captureBuffer = "oam.bmp";
rlm@1 394
rlm@1 395 LPCTSTR exts[] = {".png", ".bmp", NULL };
rlm@1 396
rlm@1 397 CString filter = winResLoadFilter(IDS_FILTER_PNG);
rlm@1 398 CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME);
rlm@1 399
rlm@1 400 FileDlg dlg(this,
rlm@1 401 captureBuffer,
rlm@1 402 filter,
rlm@1 403 theApp.captureFormat ? 2 : 1,
rlm@1 404 theApp.captureFormat ? "BMP" : "PNG",
rlm@1 405 exts,
rlm@1 406 "",
rlm@1 407 title,
rlm@1 408 true);
rlm@1 409
rlm@1 410 if (dlg.DoModal() == IDCANCEL)
rlm@1 411 {
rlm@1 412 return;
rlm@1 413 }
rlm@1 414 captureBuffer = dlg.GetPathName();
rlm@1 415
rlm@1 416 if (dlg.getFilterIndex() == 2)
rlm@1 417 saveBMP(captureBuffer);
rlm@1 418 else
rlm@1 419 savePNG(captureBuffer);
rlm@1 420 }
rlm@1 421
rlm@1 422 BOOL GBOamView::OnInitDialog()
rlm@1 423 {
rlm@1 424 CDialog::OnInitDialog();
rlm@1 425
rlm@1 426 DIALOG_SIZER_START(sz)
rlm@1 427 DIALOG_SIZER_ENTRY(IDC_OAM_VIEW, DS_SizeX | DS_SizeY)
rlm@1 428 DIALOG_SIZER_ENTRY(IDC_OAM_VIEW_ZOOM, DS_MoveX)
rlm@1 429 DIALOG_SIZER_ENTRY(IDC_REFRESH, DS_MoveY)
rlm@1 430 DIALOG_SIZER_ENTRY(IDC_SAVE, DS_MoveY)
rlm@1 431 DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
rlm@1 432 DIALOG_SIZER_ENTRY(IDC_COLOR, DS_MoveY)
rlm@1 433 DIALOG_SIZER_ENTRY(IDC_R, DS_MoveY)
rlm@1 434 DIALOG_SIZER_ENTRY(IDC_G, DS_MoveY)
rlm@1 435 DIALOG_SIZER_ENTRY(IDC_B, DS_MoveY)
rlm@1 436 DIALOG_SIZER_END()
rlm@1 437 SetData(sz,
rlm@1 438 TRUE,
rlm@1 439 HKEY_CURRENT_USER,
rlm@1 440 "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBOamView",
rlm@1 441 NULL);
rlm@1 442
rlm@1 443 m_sprite.SetWindowText("0");
rlm@1 444
rlm@1 445 updateScrollInfo();
rlm@1 446
rlm@1 447 m_stretch = regQueryDwordValue("GBOamViewStretch", 0);
rlm@1 448 if (m_stretch)
rlm@1 449 oamView.setStretch(true);
rlm@1 450 UpdateData(FALSE);
rlm@1 451
rlm@1 452 paint();
rlm@1 453
rlm@1 454 return TRUE; // return TRUE unless you set the focus to a control
rlm@1 455 // EXCEPTION: OCX Property Pages should return FALSE
rlm@1 456 }
rlm@1 457
rlm@1 458 void GBOamView::OnStretch()
rlm@1 459 {
rlm@1 460 oamView.setStretch(!oamView.getStretch());
rlm@1 461 paint();
rlm@1 462 regSetDwordValue("GBOamViewStretch", oamView.getStretch());
rlm@1 463 }
rlm@1 464
rlm@1 465 void GBOamView::OnAutoUpdate()
rlm@1 466 {
rlm@1 467 autoUpdate = !autoUpdate;
rlm@1 468 if (autoUpdate)
rlm@1 469 {
rlm@1 470 theApp.winAddUpdateListener(this);
rlm@1 471 }
rlm@1 472 else
rlm@1 473 {
rlm@1 474 theApp.winRemoveUpdateListener(this);
rlm@1 475 }
rlm@1 476 }
rlm@1 477
rlm@1 478 void GBOamView::OnChangeSprite()
rlm@1 479 {
rlm@1 480 CString buffer;
rlm@1 481 m_sprite.GetWindowText(buffer);
rlm@1 482 int n = atoi(buffer);
rlm@1 483 if (n < 0 || n > 39)
rlm@1 484 {
rlm@1 485 buffer.Format("%d", number);
rlm@1 486 m_sprite.SetWindowText(buffer);
rlm@1 487 return;
rlm@1 488 }
rlm@1 489 number = n;
rlm@1 490 paint();
rlm@1 491 updateScrollInfo();
rlm@1 492 }
rlm@1 493
rlm@1 494 void GBOamView::OnClose()
rlm@1 495 {
rlm@1 496 theApp.winRemoveUpdateListener(this);
rlm@1 497
rlm@1 498 DestroyWindow();
rlm@1 499 }
rlm@1 500
rlm@1 501 LRESULT GBOamView::OnMapInfo(WPARAM, LPARAM lParam)
rlm@1 502 {
rlm@1 503 u8 *colors = (u8 *)lParam;
rlm@1 504 oamZoom.setColors(colors);
rlm@1 505
rlm@1 506 return TRUE;
rlm@1 507 }
rlm@1 508
rlm@1 509 LRESULT GBOamView::OnColInfo(WPARAM wParam, LPARAM lParam)
rlm@1 510 {
rlm@1 511 u16 c = (u16)wParam;
rlm@1 512
rlm@1 513 color.setColor(c);
rlm@1 514
rlm@1 515 int r = (c & 0x1f);
rlm@1 516 int g = (c & 0x3e0) >> 5;
rlm@1 517 int b = (c & 0x7c00) >> 10;
rlm@1 518
rlm@1 519 CString buffer;
rlm@1 520 buffer.Format("R: %d", r);
rlm@1 521 GetDlgItem(IDC_R)->SetWindowText(buffer);
rlm@1 522
rlm@1 523 buffer.Format("G: %d", g);
rlm@1 524 GetDlgItem(IDC_G)->SetWindowText(buffer);
rlm@1 525
rlm@1 526 buffer.Format("B: %d", b);
rlm@1 527 GetDlgItem(IDC_B)->SetWindowText(buffer);
rlm@1 528
rlm@1 529 return TRUE;
rlm@1 530 }
rlm@1 531
rlm@1 532 void GBOamView::updateScrollInfo()
rlm@1 533 {
rlm@1 534 SCROLLINFO si;
rlm@1 535 ZeroMemory(&si, sizeof(si));
rlm@1 536 si.cbSize = sizeof(si);
rlm@1 537 si.fMask = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS;
rlm@1 538 si.nMin = 0;
rlm@1 539 si.nMax = 39;
rlm@1 540 si.nPage = 1;
rlm@1 541 si.nPos = number;
rlm@1 542 GetDlgItem(IDC_SCROLLBAR)->SetScrollInfo(SB_CTL,
rlm@1 543 &si,
rlm@1 544 TRUE);
rlm@1 545 }
rlm@1 546
rlm@1 547 void GBOamView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*pScrollBar)
rlm@1 548 {
rlm@1 549 switch (nSBCode)
rlm@1 550 {
rlm@1 551 case SB_BOTTOM:
rlm@1 552 number = 39;
rlm@1 553 break;
rlm@1 554 case SB_LINEDOWN:
rlm@1 555 number++;
rlm@1 556 if (number > 39)
rlm@1 557 number = 39;
rlm@1 558 break;
rlm@1 559 case SB_LINEUP:
rlm@1 560 number--;
rlm@1 561 if (number < 0)
rlm@1 562 number = 0;
rlm@1 563 break;
rlm@1 564 case SB_PAGEDOWN:
rlm@1 565 number += 16;
rlm@1 566 if (number > 39)
rlm@1 567 number = 39;
rlm@1 568 break;
rlm@1 569 case SB_PAGEUP:
rlm@1 570 number -= 16;
rlm@1 571 if (number < 0)
rlm@1 572 number = 0;
rlm@1 573 break;
rlm@1 574 case SB_TOP:
rlm@1 575 number = 0;
rlm@1 576 break;
rlm@1 577 case SB_THUMBTRACK:
rlm@1 578 number = nPos;
rlm@1 579 if (number < 0)
rlm@1 580 number = 0;
rlm@1 581 if (number > 39)
rlm@1 582 number = 39;
rlm@1 583 break;
rlm@1 584 }
rlm@1 585
rlm@1 586 updateScrollInfo();
rlm@1 587
rlm@1 588 CString buffer;
rlm@1 589 buffer.Format("%d", number);
rlm@1 590 m_sprite.SetWindowText(buffer);
rlm@1 591 paint();
rlm@1 592 }
rlm@1 593
rlm@1 594 void GBOamView::PostNcDestroy()
rlm@1 595 {
rlm@1 596 delete this;
rlm@1 597 }
rlm@1 598