@@ -680,58 +680,113 @@ void dump_pal(BITMAP *dest)
680680
681681// ----------------------------------------------------------------
682682
683+ int game_mouse_index = ZCM_BLANK;
684+ static bool system_mouse = false ;
685+ bool sys_mouse ()
686+ {
687+ system_mouse = true ;
688+ return MouseSprite::set (ZCM_NORMAL);
689+ }
690+ bool game_mouse ()
691+ {
692+ system_mouse = false ;
693+ return MouseSprite::set (game_mouse_index);
694+ }
695+ void custom_mouse (BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
696+ {
697+ if (!bmp)
698+ return ;
699+ float scale = vbound (zc_get_config (" zeldadx" ," cursor_scale_large" ,1.5 ),1.0 ,5.0 );
700+ int scaledw = bmp->w *scale, scaledh = bmp->h *scale;
701+ if (bmp->w == scaledw && bmp->h == scaledh)
702+ user_scale = false ;
703+ if (user_scale || sys_recolor)
704+ {
705+ if (!user_scale) scale = 1 ;
706+ BITMAP* tmpbmp = create_bitmap_ex (8 ,bmp->w *scale,bmp->h *scale);
707+ if (user_scale)
708+ stretch_blit (bmp, tmpbmp, 0 , 0 , bmp->w , bmp->h , 0 , 0 , tmpbmp->w , tmpbmp->h );
709+ else
710+ blit (bmp, tmpbmp, 0 , 0 , 0 , 0 , bmp->w , bmp->h );
711+ if (sys_recolor)
712+ recolor_mouse (tmpbmp);
713+ MouseSprite::assign (ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
714+ destroy_bitmap (tmpbmp);
715+ }
716+ else
717+ {
718+ MouseSprite::assign (ZCM_CUSTOM, bmp, fx, fy);
719+ }
720+ if (!system_mouse && game_mouse_index == ZCM_CUSTOM)
721+ MouseSprite::set (ZCM_CUSTOM); // Reload the new sprite
722+ }
723+
683724// Handles converting the mouse sprite from the .dat file
725+ void recolor_mouse (BITMAP* bmp)
726+ {
727+ for (int32_t x = 0 ; x < bmp->w ; ++x)
728+ {
729+ for (int32_t y = 0 ; y < bmp->h ; ++y)
730+ {
731+ int32_t color = getpixel (bmp, x, y);
732+ switch (color)
733+ {
734+ case dvc (1 ):
735+ color = jwin_pal[jcCURSORMISC];
736+ break ;
737+ case dvc (2 ):
738+ color = jwin_pal[jcCURSOROUTLINE];
739+ break ;
740+ case dvc (3 ):
741+ color = jwin_pal[jcCURSORLIGHT];
742+ break ;
743+ case dvc (5 ):
744+ color = jwin_pal[jcCURSORDARK];
745+ break ;
746+ default :
747+ continue ;
748+ }
749+ putpixel (bmp, x, y, color);
750+ }
751+ }
752+ }
684753void load_mouse ()
685754{
686755 system_pal ();
687756 MouseSprite::set (-1 );
688- int32_t sz = vbound (int32_t (16 *(zc_get_config (" zeldadx" ," cursor_scale_large" ,1.5 ))),16 ,80 );
689- for (int32_t j = 0 ; j < 4 ; ++j)
757+ float scale = vbound (zc_get_config (" zeldadx" ," cursor_scale_large" ,1.5 ),1.0 ,5.0 );
758+ int32_t sz = 16 *scale;
759+ for (int32_t j = 0 ; j < 1 ; ++j)
690760 {
691761 BITMAP* tmpbmp = create_bitmap_ex (8 ,16 ,16 );
692- BITMAP* subbmp = create_bitmap_ex (8 ,16 ,16 );
693762 if (zcmouse[j])
694763 destroy_bitmap (zcmouse[j]);
695764 zcmouse[j] = create_bitmap_ex (8 ,sz,sz);
696765 clear_bitmap (zcmouse[j]);
697766 clear_bitmap (tmpbmp);
698- clear_bitmap (subbmp);
699767 blit ((BITMAP*)datafile[BMP_MOUSE].dat ,tmpbmp,1 ,j*17 +1 ,0 ,0 ,16 ,16 );
700- for (int32_t x = 0 ; x < 16 ; ++x)
701- {
702- for (int32_t y = 0 ; y < 16 ; ++y)
703- {
704- int32_t color = getpixel (tmpbmp, x, y);
705- switch (color)
706- {
707- case dvc (1 ):
708- color = jwin_pal[jcCURSORMISC];
709- break ;
710- case dvc (2 ):
711- color = jwin_pal[jcCURSOROUTLINE];
712- break ;
713- case dvc (3 ):
714- color = jwin_pal[jcCURSORLIGHT];
715- break ;
716- case dvc (5 ):
717- color = jwin_pal[jcCURSORDARK];
718- break ;
719- }
720- putpixel (subbmp, x, y, color);
721- }
722- }
768+ recolor_mouse (tmpbmp);
723769 if (sz!=16 )
724- stretch_blit (subbmp , zcmouse[j], 0 , 0 , 16 , 16 , 0 , 0 , sz, sz);
770+ stretch_blit (tmpbmp , zcmouse[j], 0 , 0 , 16 , 16 , 0 , 0 , sz, sz);
725771 else
726- blit (subbmp , zcmouse[j], 0 , 0 , 0 , 0 , 16 , 16 );
772+ blit (tmpbmp , zcmouse[j], 0 , 0 , 0 , 0 , 16 , 16 );
727773 destroy_bitmap (tmpbmp);
728- destroy_bitmap (subbmp);
729774 }
730775 zc_set_palette (*hw_palette);
731776
732- MouseSprite::assign (0 , zcmouse[0 ]);
733- MouseSprite::set (0 );
777+ BITMAP* blankmouse = create_bitmap_ex (8 ,16 ,16 );
778+ clear_bitmap (blankmouse);
779+
780+ MouseSprite::assign (ZCM_NORMAL, zcmouse[0 ], 1 *scale, 1 *scale);
781+ MouseSprite::assign (ZCM_BLANK, blankmouse);
782+ // Don't assign ZCM_CUSTOM. That'll be handled by scripts.
783+
784+ // Reload the mouse
785+ if (system_mouse)
786+ sys_mouse ();
787+ else game_mouse ();
734788
789+ destroy_bitmap (blankmouse);
735790 game_pal ();
736791}
737792
@@ -745,7 +800,7 @@ bool game_vid_mode(int32_t mode,int32_t wait)
745800
746801 scrx = (resx-320 )>>1 ;
747802 scry = (resy-240 )>>1 ;
748- for (int32_t q = 0 ; q < 4 ; ++q)
803+ for (int32_t q = 0 ; q < NUM_ZCMOUSE ; ++q)
749804 zcmouse[q] = NULL ;
750805 load_mouse ();
751806
@@ -4248,6 +4303,7 @@ void f_Quit(int32_t type)
42484303 {
42494304 music_pause ();
42504305 pause_all_sfx ();
4306+ sys_mouse ();
42514307 }
42524308 enter_sys_pal ();
42534309 clear_keybuf ();
@@ -4291,6 +4347,7 @@ void f_Quit(int32_t type)
42914347 }
42924348
42934349 if (!from_menu)
4350+ game_mouse ();
42944351 eat_buttons ();
42954352
42964353 zc_readrawkey (KEY_ESC);
@@ -6342,11 +6399,13 @@ int32_t onGoToComplete()
63426399 system_pal ();
63436400 music_pause ();
63446401 pause_all_sfx ();
6402+ sys_mouse ();
63456403 onGoTo ();
63466404 eat_buttons ();
63476405
63486406 zc_readrawkey (KEY_ESC);
6349-
6407+
6408+ game_mouse ();
63506409 game_pal ();
63516410 music_resume ();
63526411 resume_all_sfx ();
@@ -8332,6 +8391,7 @@ void System()
83328391 misc_menu[5 ].flags = Playing ? 0 : D_DISABLED;
83338392 misc_menu[7 ].flags = !Playing ? 0 : D_DISABLED;
83348393 clear_keybuf ();
8394+ sys_mouse ();
83358395
83368396 DIALOG_PLAYER *p;
83378397
@@ -8467,6 +8527,7 @@ void System()
84678527 // font=oldfont;
84688528 mouse_down=gui_mouse_b ();
84698529 shutdown_dialog (p);
8530+ game_mouse ();
84708531 MenuOpen = false ;
84718532 if (Quit)
84728533 {
0 commit comments